I’m trying this quiz in the Chrome console: Quiz
I can explain most of them somewhat after trying them out. But one thing confuses me:
var x = [typeof x, typeof y][1];
typeof typeof x;
…. returns “string”, which doesn’t make any sense to me.
var x = [typeof x, typeof y][1];
returns “undefined”
typeof "undefined"
returns “string”, which makes some sense because undefined was in quotes. But overall, I don’t see the purpose of “undefined” in coexistance with undefined. Also, what kind of array syntax is that? “Javascript The Good Parts” says that there are no multidimensional arrays.
undefinedis actuallywindow.undefinedin most situations. It’s just a variable.window.undefinedhappens to not be defined, unless someone defines it (tryundefined = 1andtypeof undefinedwill be"number").typeofis an operator that always returns a string, describing the type of a value.typeof window.undefinedgives you"undefined"– again, just a string.typeof "undefined"gives"string", just liketypeof "foo"would.typeof typeof undefinedgives"string".In relation to this syntax:
That’s not a multi-dimensional array – it is merely creating an array first
arr = [1, 2], and then selecting element 1 from it:arr[1].