Reasons to hate JavaScript #1098708976 let x = "a string" (x instanceof String) // returns false Because x isn't a String object yet. It's a literal. It only gets upgraded to an object when and if you call an object method/property on it, like x.trim() or x.length
-
Show this thread
-
Replying to @AmeliasBrain
What do you mean by “gets upgraded”? I guess I’m misunderstanding that last sentence.pic.twitter.com/slCJDaykut
1 reply 0 retweets 2 likes -
Replying to @mathias
Yeah, "upgrade" is probably not the best word. I meant: when you use a . operator on a literal, the literal is coerced to an object to find the method/prop. It isn't persistent / doesn't affect output. (PS works for numbers, too, but only if . it isn't parsed as a decimal!)pic.twitter.com/owgxEPaa5x
3 replies 1 retweet 9 likes
Replying to @AmeliasBrain
Right, I misinterpreted. Thanks for clarifying!
2:54 PM - 23 Nov 2017
0 replies
0 retweets
0 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.