Jak używać w JavaScript
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
Dark Dunlin
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
const array = [1, 2, 3];array.forEach(function(elem, index, array) { array[index] = elem * 2;});console.log(array); // [2,4,6]
const iterable = new Set([1, 1, 2, 2, 3, 3]);
for (const value of iterable) {
console.log(value);
}
// 1
// 2
// 3
for (variable of iterable) {
statement
}
const array = [1,2,3,4,5];const evenNumbers = array.filter(function(elem) { // expressions that return 'true' are retained return elem % 2 == 0;});