Skip to content

Instantly share code, notes, and snippets.

@conanak99

conanak99/for.js Secret

Last active Mar 9, 2016
Embed
What would you like to do?
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// Cách cũ, duyệt từ đầu
for(var i = 0; i< numbers.length; i ++)
{
console.log(number[i]);
}
// Dùng forEach
numbers.forEach(function(number) {
console.log(number);
})
// Dùng for...of, dễ viết dễ đọc
for(var number of numbers) console.log(number);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment