[variables] fix variable hoisting example. fixes #265

This commit is contained in:
Harrison Shoff
2015-04-19 15:42:15 -07:00
parent 10ef68a4ab
commit 7fe4883a75

View File

@@ -447,7 +447,7 @@
return name;
}
// bad
// bad - unnessary function call
function() {
var name = getName();
@@ -455,16 +455,21 @@
return false;
}
this.setFirstName(name);
return true;
}
// good
function() {
var name;
if (!arguments.length) {
return false;
}
var name = getName();
name = getName();
this.setFirstName(name);
return true;
}