I know this
is probably the second most asked-about thing in javascript, right after floating point arithmetic.
I generally know how this
works, and how it's affected by arrow functions, .call()
, .apply()
, and .bind()
. I thought I understood everything about it. But I do not.
In a web browser, document.createElement("div").classList.add("c")
yields undefined
as expected. However, this expression surprisingly is an error.
(true && document.createElement("div").classList.add)("c")
I expected it to be the same, but it's
Uncaught TypeError: Illegal invocation
at <anonymous>:1:54