Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var persons = ["Gosling", "Bool", "Babbage", "Knuth", "Turing", "Lovelace"];
- // will print index:personname
- for (var i in persons) {
- if (window.console) {console.log(i + ":" + persons[i]);}
- }
- // will print index:personname, and the original array (each time)
- persons.forEach(function(entry, index, array) {
- if (window.console) {console.log(index + ":" + entry);}
- if (window.console) {console.log(array);}
- });
- // will print personname
- for (var x of persons) {
- if (window.console) {console.log(x);}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement