Introduction to JS
Introduction Of Javascript
Our Javascript is an object based language. Here we direct create the object to solve out our entity. Everything near us can be the objects like chair, pen, Comb, etc. We have some ways to create the objects which are described as follows:-:-
Creating object by object literal
Syntax
object={property1 : value1 , property2 : value2...propertyN : valueN}
Let's take an example:-
This is one way how we create the object.
Creating instance of Object
We use the new keyword to create an object
Syntax
var object = new Object();
Let's take an example:-
This is other way how we create the object.
Using the object constructor
In this way first we create any function with arguments and we can also use this keyword here which refers to the current object.
Let's take an example:-
This is third way how we create the object.
Some more methods and description below :-
Methods | Description |
---|---|
Object.assign() | This method is used to copy enumerable and own properties from a source object to a target object |
Object.create() | This method is used to create a new object with the specified prototype object and properties. |
Object.defineProperty() | This method is used to describe some behavioral attributes of the property. |
Object.is() | This method determines whether two values are the same value. |
Object.isExtensible() | This method determines if an object is extensible |
Object.isFrozen() | This method determines if an object was frozen. |
Object.isSealed() | This method determines if an object is sealed. |
Object.keys() | This method returns an array of a given object's own property names. |
Object.preventExtensions() | This method is used to prevent any extensions of an object. |
Object.seal() | This method prevents new properties from being added and marks all existing properties as non-configurable. |
Object.setPrototypeOf() | This method sets the prototype of a specified object to another object. |
Object.values() | This method returns an array of values. |
JS training insitute | Best IT Training classes in Gurgaon | Web Designing Training Institute