japrescott
Re:Show HN: A Javascript quiz that explores how javascript scopes its ...
on Monday August 27, 2012 @03:54AM (#4437863)
veryvery superb quiz! I like the way you mix questions with a tutorial, not just "HA, you suck, wrong", but really give detailed explanations, even when the correct answer is given.
Maybe you can add some questions with strange return values or some "what happens if you modify the passed-in object within a function?";
function(){ 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!
Re:Show HN: A Javascript quiz that explores how javascript scopes its ...
on Monday August 27, 2012 @03:44AM (#4437844)
not true. boolean, strings, numbers (int, float) are passed by value, while Objects, Arrays and Functions are passed by reference!