Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. var persons = ["Gosling", "Bool", "Babbage", "Knuth", "Turing", "Lovelace"];
  2.  
  3. // will print index:personname
  4. for (var i in persons) {
  5. if (window.console) {console.log(i + ":" + persons[i]);}
  6. }
  7.  
  8. // will print index:personname, and the original array (each time)
  9. persons.forEach(function(entry, index, array) {
  10. if (window.console) {console.log(index + ":" + entry);}
  11. if (window.console) {console.log(array);}
  12. });
  13.  
  14. // will print personname
  15. for (var x of persons) {
  16. if (window.console) {console.log(x);}
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement