What are objects in Javascript and How are the defined

April 19, 2020 By Nobody No Body

In Java script almost everything can be considered under objects. Even booleans can be considered as object we add new keyword to it. Only primitives of Java script are not considered as objects. Primitive data types are the data types which do not have any value. The primitive data types are hard coded and they cannot be changed. Lets take an example of primitive data type.

For example Var x = 6.38

In the above example we can change the value of X but we cannot change the value of 6.38 so here 6.38 is considered as primitive data type and it is not an object.

Objects are also variable in some cases. Lets look onto an example in such case.

var kiran = “Sai”;

Here kiran is a variable, at the same time he can also be an object. In this case when Kiran is a variable, he can contain certain value but when he is an object then he can contant a lot of values. This is he difference between objects and variables.

The values which are named in objects are called properties. Values can be defined inside an object according to the requirement. Actions performed on the objects are called Object methods. Object method is a function containing object property. You can define and create your own objects in Javascript by using a keyword new.