Augment the Array type
I'm trying to augment Array
as follows:
Array.prototype.myFunction = function () { return 10; }
But then, the following doesn't work:
var myArray = "Bla"
myArray.myFunction();
What's the stup开发者_如何学JAVAid mistake I'm doing?
Because "Bla"
is not an Array
. Its a String
.
精彩评论