Answered by : dan
// one liner
await new Promise(resolve => setTimeout(resolve, 5000));
// or re-usable `sleep` function:
async function init() { console.log(1); await sleep(1000); console.log(2);
}
function sleep(ms) { return new Promise((resolve) => { setTimeout(resolve, ms); });
}
Source : https://stackoverflow.com/questions/14249506/how-can-i-wait-in-node-js-javascript-l-need-to-pause-for-a-period-of-time | Last Update : Tue, 07 Apr 20
Answered by : khalid-sm0131mwatqd
{"tags":[{"tag":"p","content":"For Loop"},{"tag":"textarea","content":"for (expression 1; expression 2; expression 3) {\n \/\/ code block to be executed\n}","code_language":"javascript"},{"tag":"p","content":"Example of For Loop"},{"tag":"textarea","content":"for(let i = 0; i < arr.length; i++){\n \/\/ code block to be executed\n}","code_language":"javascript"},{"tag":"p","content":"For In Loop"},{"tag":"textarea","content":"for (key in object) {\n \/\/ code block to be executed\n}","code_language":"javascript"},{"tag":"p","content":"Example of For In Loop "},{"tag":"textarea","content":"for (let x in arr) {\n \/\/ code block to be executed\n}","code_language":"javascript"},{"tag":"p","content":"For Of Loop "},{"tag":"textarea","content":"for (variable of iterable) {\n \/\/ code block to be executed\n}","code_language":"javascript"},{"tag":"p","content":"Example of For Of Loop "},{"tag":"textarea","content":"for (let x of arr) {\n \/\/ code block to be executed\n}","code_language":"javascript"},{"tag":"p","content":"While Loop"},{"tag":"textarea","content":"while (condition) {\n \/\/ code block to be executed\n}","code_language":"javascript"},{"tag":"p","content":" Example of While Loop"},{"tag":"textarea","content":"while (i < 10) {\n \/\/ code block to be executed\n i++;\n}","code_language":"javascript"}]}
Source : | Last Update : Mon, 17 Apr 23
Answered by : friendly-fox-qsngmqv2p743
var arr = [1, 2, 3, 4, 5];
arr.slice().reverse()
.forEach(function(item) {
console.log(item);
});
Source : https://www.techiedelight.com/loop-through-array-backwards-javascript/ | Last Update : Wed, 02 Mar 22
Answered by : famous-flatworm-zpybj14joo6z
for (let step = 0; step < 5; step++) { // Runs 5 times, with values of step 0 through 4. console.log('Walking east one step');
}
Source : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration | Last Update : Mon, 17 Jan 22
Answered by : repulsive-rook-iipm013pd1vq
for (var i =0;i<1;i++){
}
Source : | Last Update : Wed, 27 Apr 22
Answered by : debashis-roy
for - loops through a block of code a number of times
for/in - loops through the properties of an object
for/of - loops through the values of an iterable object
while - loops through a block of code while a specified condition is true
do/while - also loops through a block of code while a specified condition is true
for (let i = 0; i < cars.length; i++) { text += cars[i] + "<br>";
}
Source : | Last Update : Mon, 27 Jun 22
Answered by : tarig-slah
javascript loop
Source : | Last Update : Sat, 06 Aug 22
Answered by : zouari-mehdi
Serial.println(value);
Source : https://www.tinkercad.com/things/dA2x56lhYb7-brave-curcan/editel?tenant=circuits | Last Update : Fri, 07 Jan 22
Answered by : black-snake
const numbers = [1,2,3,4,5];
const sum = 0;
numbers.forEach(num => { sum += num });
Source : https://stackoverflow.com/questions/3010840/loop-through-an-array-in-javascript | Last Update : Sun, 08 May 22
Answered by : kalkidan-dereje
{"tags":[{"tag":"textarea","content":"$ npm i -g @nestjs\/cli\n$ nest new project-name","code_language":"whatever"}]}
Source : https://docs.nestjs.com/first-steps | Last Update : Fri, 10 Feb 23