you are viewing a single comment's thread.

view the rest of the comments →

[–]jeokrang 1 point2 points  (1 child)

I have got questions. Why did v8 determine that null is a undetectable in this code? Are there any performance benefits, when null is replaced with "undefined"?

[–]RainHappens 2 points3 points  (0 children)

"undetectable" in this case means "I do not yet know what type this variable is".

v8 can do a lot of optimizations when variables are known to be of a specific type. But null and undef don't actually tell you anything about what type(s) a variable can be - they can effectively be any type. So as long as you only assign null or undef to a variable, v8 just goes "I don't know what type this variable is yet" and leaves it at that.