I find it fascinating how these two codes exhibit different behaviors. It's interesting to note that functions like 'console.log' would work in both scenarios, but localStorage API functions such as getItem and setItem do not.
setTimeout(()=>localStorage.setItem('1','2'),1000)
// setTimeout(code, delay) works
setTimeout(localStorage.setItem,1000,'1','2')
// setTimeout(functionRef, delay, param1) does not work, resulting in an error message "Uncaught TypeError: Illegal invocation"
However, according to Mozilla, both formats should function correctly. I am curious about the underlying logic behind this discrepancy. Would you mind sharing some insights with me? Thank you very much :)