开发者

Augment the Array type

开发者 https://www.devze.com 2023-04-01 10:31 出处:网络
I\'m trying to augment Array as follows: Array.prototype.myFunction = function () { return 10; } But then, the following doesn\'t work:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消