Guest User

Untitled

a guest
May 23rd, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. var popup = "something..."
  2.  
  3. var popups = [];
  4.  
  5. // Add with .push()
  6. popups.push("something");
  7. popups.push("something else");
  8.  
  9. // Remove with .splice()
  10. // to remove the first element popups[0]
  11. popups.splice(0, 1);
  12.  
  13. popups.push("third thing");
  14. popups.push("fourth thing");
  15.  
  16. console.log(popups);
  17. // ["something else", "third thing", "fourth thing"]
  18.  
  19. // Remove the current second item popups[1]
  20. popups.splice(1,1);
  21.  
  22. console.log(popups);
  23. // ["something else", "fourth thing"]
  24.  
  25. for (var i=0; i<popups.length; i++) {
  26. if (popups[i] === valueToRemove) {
  27. popups.splice(i, 1);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment