“dla i w JavaScript” Kod odpowiedzi

JavaScript za

const array = ['hello', 'world', 'of', 'Corona'];

for (const item of array) {
  console.log(item);
}
2 Programmers 1 Bug

dla JavaScript

let arr = ["a", "b", "c"]

for (let i in arr){
  console.log(i) // 0, 1, 2
}

for(let i of arr){
  console.log(i) // a, b, c
}
Friendly Fox

Jak używać w JavaScript

const array1 = ['a', 'b', 'c'];

for (const element of array1) {
  console.log(element);
}
Dark Dunlin

dla JS lub w pętli w JS

let list = [10, 11, 12];

for (let i in list) {
   console.log(i); //Display the indices: "0", "1", "2",
}

for (let i of list) {
   console.log(i); // Display the elements: "10", "11", "12"
}
Moscode

W JS i za

Object.prototype.objCustom = function () {}; 
Array.prototype.arrCustom = function () {};

let iterable = [3, 5, 7];
iterable.foo = "hello";

for (let i in iterable) {
  console.log(i); // logs 0, 1, 2, "foo", "arrCustom", "objCustom"
}

for (let i of iterable) {
  console.log(i); // logs 3, 5, 7
}
Modern Mandrill

JavaScript za

const numbers = [1,2,3,4];

for(const item of numbers){
  console.log(item);
}
hateschoollovecoding

Odpowiedzi podobne do “dla i w JavaScript”

Pytania podobne do “dla i w JavaScript”

Więcej pokrewnych odpowiedzi na “dla i w JavaScript” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu