Using many


I have a loop and need to open new window in a new tab many times:

items.forEach((item) => {
console.log("here") // Doesn't work

But executes only 1 time.

Also other functions not executing.
What I supposed to do?


Use '_blank' as second param of"url",'_blank');

or set a specific window title for each item (prevent same because it’ll open in same ):

items.forEach((item) => {
   // below I used url as title , if you have title attribute 
   // you can set item.title instead,item.url) 

For example try pasting below code in console , it should open 2 tabs :
check this in console :

[{"url":"","title":"google"},{"url":"","title":"stackoverflow"}].forEach((item) => {,'_blank')
    // or use 

Answered By – Spring

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published