JavaScript Demo: array.forEach
Hi Reader,
Today I am going to discuss the important loop which is comptaible with "foreach" loop of PHP. The annotation of foreach loop in javascript is "forEach" i.e. camel case characters.
You can place following javascript code in your html page:-
Today I am going to discuss the important loop which is comptaible with "foreach" loop of PHP. The annotation of foreach loop in javascript is "forEach" i.e. camel case characters.
You can place following javascript code in your html page:-
var array = ['a', 'b', 'c', 'd', 'e'];
array.forEach(function(char){
console.log("Output character:- "+char);
});
array.forEach(function(char){
console.log("Output character:- "+char);
});
Then open console of your browser and check following output:-
- Output character:- a
- Output character:- b
- Output character:- c
- Output character:- d
- Output character:- e
As you can see in following screenshot of my POC that I made for demo purpose:-
Thanks for reading by blog. Please comment your reviews, even if you like it or not. Most welcome your suggestions. Share with in your network.
Comments
Post a Comment
Please give your valuable feedback!