Warning: Undefined array key 1 in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 50

Deprecated: urldecode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 50

Warning: Undefined array key 1 in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 51

Deprecated: urldecode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 51

Warning: Undefined array key 1 in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 56

Warning: Constant HOST already defined in /home/wikitechy/public_html/tutorials/node-js/config.php on line 7

Warning: Constant BASE_URL already defined in /home/wikitechy/public_html/tutorials/node-js/config.php on line 8

Warning: Constant BASE_HREF already defined in /home/wikitechy/public_html/tutorials/node-js/config.php on line 9

Warning: Constant IMG_URL already defined in /home/wikitechy/public_html/tutorials/node-js/config.php on line 10
[100% Working Code] - Node js - Foreach Loop - node js tutorial - wikitechy

Node js - Foreach Loop - Node JS tutorial



For Loop

  • It is an advanced looping structure which is used in traversing items in a collection. It is executed until the collection set is over.
  • Difference from for loop is that it works with variables but foreach works with the object.
  • Foreach loops usually doesn’t have any explicit counter.
 nodejs foreach loop

Learn Nodejs - Nodejs tutorial - nodejs foreach loop - Nodejs examples - Nodejs programs

Sample code :

a=[1,2,3];
a.forEach((v) => {
console.log("The value of a is :"+v);
});

Read Also

For Loop in C

Code Explanation :

 nodejs foreach loop code

Learn Nodejs - Nodejs tutorial - nodejs foreach loop code - Nodejs examples - Nodejs programs

  • Array object is declared as a=[1,2,3];
  • Foreach loop on a is written such that foreach value v from the object a, the value is written to the console. The following code given below.
a.forEach((v) => {
console.log("The value of a is :"+v);
});

Output :

 nodejs foreach loop code output

Learn Nodejs - Nodejs tutorial - nodejs foreach loop code output - Nodejs examples - Nodejs programs

Read Also

Java For Loop

Related Searches to node.js - Foreach Loop - Node.js tutorial