Better HN
topnewbestaskshowjobs
Log inSign up

japrescott

2 karma · joined Aug 27, 2012 (14y ago) · 2 submissions

Submissions

comment 14y ago · link · parent

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!

comment 14y ago · link · parent

not true. boolean, strings, numbers (int, float) are passed by value, while Objects, Arrays and Functions are passed by reference!