E2EHIRING Logo
Jobs
Jobs
courses
Courses
mentorship
Mentorship
more
Moredropdown
E2EHIRING Logo
more
Jobs
Jobs
courses
Courses
mentorship
Mentorship
HomeSepratorIconBlogsSepratorIconJavaScript ObjectsSepratorIcon

JavaScript Objects

Han SoloSanthiya V
calendar18 Jul 2022
poster

OBJECT METHODS

                     In JavaScript, an object is an unordered collection of key-value pairs. Each key-value pair is called a property. The key of a property can be a string. And the value of a property can be any value, e.g., a string, a number, an array, and even a function.

Now lets start to learn the Object methods...


1.Object.assign( )

                   The Object.assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. Objects are assigned and copied by reference. It will return the target object.

Syntax:-
         Object.assign(target,source)

Example:-
const value={fname:"rithika",height:5},
const  value1 ={location:"kovai",height:6},
const answer=Object.assign(value,value1);
console.log(answer);{fname:'rithika',location:'kovai',height:6}

2.Object.entries( )

                    JavaScript Object.entries() method is used to return an array of a given object's own enumerable property [key, value] pairs.

Syntax:-
         Object.entries(object)

Example:-
const data={
id:1,
education:"B.Com",
college:"Bharathiyar University",
passedout:2019
}
const output=Object.entries(data);
console.log(output);//['id',1]['education ',B.Com]['college ','Bharathiyar University ']['passedout ','2019'] 

3.Object.freeze( )

               The Object.freeze() method freezes an object that prevents new properties from being added to it. This method prevents the modification of existing property, attributes, and values. 

Syntax:-
         Object.freeze(object)

Example:-
const mark={
Tamil:72,
English:55,
Maths:44
}
mark.Science=63;
const final=Object.freeze(mark);
mark.Social=49;
console.log(final);//{ Tamil:72,  English:55, Maths:44, Science :63}

4.Object.create( )

               The Object.create() method is used to create a new object with the specified prototype object and properties. 

Syntax:-
             Object.create(proto, propertiesObject)

Example:-
const details ={ 
city: 'Pollaci',  
district:'Coimbatore',
fullData: function(){   
 console.log(`my village name is ${this.city} in the state of ${this.state} and famous for ${this.famous} .`); }
}
const personal = Object.create(details);
personal.famous = "cotton and temple";
personal.state = "Tamilnadu";
personal.fullData();//my city  name is Pollachi in the state of Tamilnadu and famous for cotton and temple.


5.Object.is( )

                           This method determines whether two values are same or not. It will return the boolean value.

Syntax:-
         Object.is(value1,value2)

Example:-
const obj={
language:"tamil"
}
const same=Object.is(obj,obj);
console.log(same);//true


const number=Object.is(12,-12);
console.log(number);//false

 Thank you...


Recent Posts

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

How to publish your Android app on Google Play Store

How to publish your Android app on Google Play Store

Creating Dynamic User Interfaces with Android Motion Layout

Creating Dynamic User Interfaces with Android Motion Layout

Bean Life Cycle

Bean Life Cycle

Pom.XML

Pom.XML

copycopycopycopy

Han Solo

Recent Posts

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

How to publish your Android app on Google Play Store

How to publish your Android app on Google Play Store

Creating Dynamic User Interfaces with Android Motion Layout

Creating Dynamic User Interfaces with Android Motion Layout

Bean Life Cycle

Bean Life Cycle

Pom.XML

Pom.XML