mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-13 22:38:08 -05:00
Merge pull request #317 from airbnb/fix-var-example
[variables] fix variable hoisting example. fixes #265
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user