var a=[1,2,3,4]
function Demo(){}
Array.prototype={
foo:function(){
alert(1)
}
}//a.foo is not a function
Array.prototype.foo=function(){
alert(1)
}//alert(1)
a.foo()
Demo.prototype={
foo:function(){
alert(1)
}
}
var b=new Demo()
b.foo()//alert(1)
Why can't Array add prototype with literals? Also, why does it work when I use a constructor?
Here is an example: https://jsbin.com/zowalu/edit?js,console