You're missing a semicolon:
Array.prototype.method1 = function() {
console.log("method1 called");
}; // <--- Hi there!
[1,2,3,4].method1();
What?
Semicolons are optional in javascript, so the code you wrote is equivalent to:
Array.prototype.method1 = function() { ... }[1,2,3,4].method1();
// after evaluating the comma operator:
Array.prototype.method1 = function() { ... }[4].method1();
// naturally, functions don't have a fourth index
undefined.method1();
// Error :(
Be careful with your semicolons!
Some reading material:
console.log([1,2,3,4].method1());prints out undefined (in your fiddle) since method1 does not return any string itself.;after the function definition. JavaScript treatsfunction () {..}[1, 2, 3,4]as a Single expression. And since it returnsundefined, you are getting the error.