javascript - Calling array prototype function -


i tried in chrome, reason of not ok below?

 array.prototype.ts= function () {           alert("hallo")       }  [1, 9, 8, 7, 6, 5, 3, 4, 5, 2, 0].ts(); //not ok - reason? ([1, 9, 8, 7, 6, 5, 3, 4, 5, 2, 0]).ts(); //ok 

you missing semi-colon after function declaration. here running in chrome console , seeing work should. see below fiddle

array.prototype.ts = function() { alert('test') };  [1,2,3].ts()


Comments