Created
June 20, 2014 07:37
-
-
Save mingtsay/0ea8606a953ff23bfb58 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.sayHi = function () { | |
var say = 'Hi, ' + this.join(', ') + '!'; | |
window.alert(say); | |
} | |
var a = ['Bob', 'Alice', 'Emma']; | |
a.sayHi(); // this will alert: Hi, Bob, Alice, Emma! | |
for (var i in a) { | |
console.log(i, a.hasOwnProperty(i), a[i]); | |
} | |
/* console will show the following: | |
* "0" true "Bob" | |
* "1" true "Alice" | |
* "2" true "Emma" | |
* "sayHi" false function | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment