Why I’m in the everything is an object in Javascript crowd.

First, let me point out that javascript is not java, and that all things in a programming language are things. If all things have a common inheritance then they are all of that same thing they inherit.

Second, the distinction of  where the inheritance of a thing comes from does not change the functionality of the thing. It helps in understanding some of its behaviors. If a type of animal is a classified as carnivorous we know that it eats meat, but that does not mean it can be substituted for other meat eating animals. Some carnivores hunt and some do not.

The first two points should convey the understanding that within this post saying everything is an object we are saying this for classification purposes and to understand their behaviors in a way that makes sense. An array is one type of object and the functionality of a number is not the same as an array. 

In javascript inheritance is based on a prototype system. Objects inherit the prototype values from of a global object.

Object.prototype.isobject = true;

 When new objects are created.

var a=1;

The new objects inherit the methods, properties, etc of which they came from.

document.write(a.isobject); /* true */


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: