38
loading...
This website collects cookies to deliver better user experience
Loops
wowww 😃, incredible, it sound really strange, it's petty similar to the concept you already know.Hello
in console twice without writing the console.log
statement twice.console.log("Hola");
console.log("Hola");
looping
:for(let i =0; i<2; i++) {
console.log("Hola");
}
console.log("Hello")
1000 times?YES
, let me say you're crazy 👨🏻💻loops
but there are more methods to achieve this aim
😇 when you are trying to parse an array
, let's see an example:const data = ["a", "b", "c"]
for (let item of data) {
console.log(item);
}
loops
to get each key of a key-value pair (objects), let's see an example:const data = {
"a": 1,
"b": 2,
"c": 3
}
for (let key in data) {
console.log(`key: ${key} @ value: ${data[key]}`);
}
key-value
from the above object, it allows us to load an object without knowing anything about the length or the properties it could have. objects
, arrays
. looping
, for example a forEach
sentence, which return a callback
with the execution for each value, let's see an example:[1,2,4].forEach((value, index) => {
console.log(`The value in index ${index} is ${value}`)
});
map
but its aim isn't exactly to iterate each item on a array, we'll see it on the following posts.looping
means and how it looks using JS.