Created
April 28, 2017 20:22
-
-
Save SergeyLipko/a6ab03dc5a82d2b1c00c5a0b6741a122 to your computer and use it in GitHub Desktop.
This file contains 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
// ля получения значений подобно циклу for...of, можно использовать метод | |
let arr = [ 3, 5, 7 ]; | |
arr.foo = "hello"; | |
arr.forEach(function (element, index) { | |
console.log(element); // выведет "3", "5", "7" | |
console.log(index); // выведет "0", "1", "2" | |
}); | |
// или при помощи Object.keys() | |
Object.keys(arr).forEach(function (element, index) { | |
console.log(arr[element]); // выведет "3", "5", "7", "hello" | |
console.log(arr[index]); // выведет "3", "5", "7" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment