Created
May 21, 2017 08:25
-
-
Save juwencheng/e46ce70f5e0d6a6e1876433f80207ce6 to your computer and use it in GitHub Desktop.
simple demo shows usage of array function
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
let numbers = [2, 3, 4, 5, 6, 7] | |
let doubled = numbers.map((n) => n * 2); | |
console.log(doubled); | |
let person = { | |
name: 'Ryan', | |
hobbies: ['Robots', 'Computers', 'Internet'], | |
showHobbies: function() { | |
// this.name undefined | |
// this.hobbies.forEach(function(hobby){ | |
// console.log(`${this.name} likes ${hobby}` | |
// }) | |
this.hobbies.forEach(hobby => { | |
console.log(`${this.name} likes ${hobby}` | |
}) | |
}, | |
sayName() { | |
console.log(`Hi I am ${this.name}`); | |
} | |
} | |
person.sayName(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment