You can test this for yourself (using the Node REPL, but will work in FF, Chrome, IE, etc)
> Object.prototype.test()
TypeError: Object #<Object> has no method 'test'
at repl:1:19
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:98:17)
at emitKey (readline.js:1095:12)
> Array.prototype.test()
TypeError: Object has no method 'test'
at repl:1:18
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:98:17)
at emitKey (readline.js:1095:12)
> Object.prototype.test = function(){console.log('test');}
[Function]
> Array.prototype.test()
test
undefined
>
> Object.prototype.test()
test
undefined
> String.prototype.test()
test
undefined
If the Array
prototype didn't include the Object
prototype, this wouldn't work -- everything that is an object in JavaScript eventually has the Object.prototype
as it's "parent".