Show HN: A Javascript quiz that explores how javascript scopes its variables
1–10 of 12 posts
Re: Show HN: A Javascript quiz that explores how javascript scopes its variables
#2See https://developer.mozilla.org/en-US/docs/JavaScript/Referenc...
> In the global context (outside of any function), this refers to the global object, whether in strict mode or not.
Re: Show HN: A Javascript quiz that explores how javascript scopes its variables
#3Re: Show HN: A Javascript quiz that explores how javascript scopes its variables
#4Re: Show HN: A Javascript quiz that explores how javascript scopes its variables
#5Re: Show HN: A Javascript quiz that explores how javascript scopes its variables
#6Re: Show HN: A Javascript quiz that explores how javascript scopes its variables
#7You might want to consider including something about how passing objects between functions can be by reference or value for object oriented Javascript programming.
Re: Show HN: A Javascript quiz that explores how javascript scopes its variables
#8You might want to consider including something about how passing objects between functions can be by reference or value for object oriented Javascript programming.
JavaScript only supports pass by value, @ author: Nice quiz, I failed the last one, it would be nice to add more quizes and test users knowledge of function scoping, just like the commenter said, since functions can be passed around like objects, function scoping is another tricky one to master for beginners.
Re: Show HN: A Javascript quiz that explores how javascript scopes its variables
#9function(){ var fn2=function(){} if (fn2()){ alert("nobody ever calls me"); } else{ alert("stop calling me!"); } } (no return value is a falsy value)
var data={a:"cow"}; function update(obj){ obj.a="fish"; } update(data); alert(data.a); //"fish"
vs.
var data="cow"; function update(str){ str="fish"; } update(data); alert(data); //"cow"
keep up the great work!