Javascript Object


unschoolingcode

In JS almost every thing is object.A variable is object,a function is object,Date is object,boolean is object,array,regex,maths are all object.
However the primitive value variables are not object.

exampe

The v is a variable of type string.
Is it an object too?
No, because it is a primitive variable.

Don’t get confused, a variable can have only one value while a object can have many values.
Objects are variables too but can contain multiple value.
example:

It has name:value pair separated by colons.
The name,age are called properties.

Example

Creating a javascript object
We have several ways to create javascript object.They are explained below.

1. Using an Object Literal

Just as the above example.

2.Using keyword ‘new’.

3. Using an Object Construct
In the above two ways of creating object, we can create a single object.Sometimes we need to create many object of one type.In such case this method…

View original post 104 more words

Advertisements

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