Created
May 28, 2015 12:32
-
-
Save wende/e8cb6947dd4979e7a517 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tu standard | |
function Person(name, age){ | |
this.name = name | |
this.age = age | |
} | |
// Literał jest szybszy niż new Array() i lepiej wygląda | |
var family = [ | |
new Person("alice", 40) | |
new Person("bob", 40) | |
new Person("michele", 40) | |
new Person("timmy", 40) | |
] | |
// zmienna tymczasowa dla perfomancu | |
var l = family.length | |
// lepiej dać vara dla bezpieczeństwa niż niszczyć scope | |
for(var i = 0; i < l; i++) console.log(family[i].name) | |
// a jeszcze lepiej funkcyjnie | |
family.map( function(a){ console.log(a.name) }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment