Calling functions in Object.Prototype from Object

I added a function to Object.prototype using Object.prototype.func = function () {...} but when I try to call it using Object.func() it throws an error that it is not defined in Object.

Answers


Everything in JavaScript is an object and inherits from Object (including Object). If there's a property on Object.prototype then EVERYTHING can access it because it is in everything's prototype.

http://jsfiddle.net/PxLDu/1/


Need Your Help

Automatically resize image to fit Flex Slider

javascript flexslider

I am learning how to use Flex Slider to make image sliders and carousels. However, Flex only seems to be good when all the images are of the exact same width and height.

Draw line in Cocoa?

objective-c osx drawing nsbezierpath

How i can draw a line in a specific window after a button click?