Javascript Call Method

Hello guyz we have some built in default methods in javascript which we can call explicitly.

Below is an example which shows how to use call() method on javascript objects.

const getDetails = {
  getFullName : function(){
    return "Hey this is "+this.fname+" "+this.lname;
  }
};

const cloudWeb = {fname:"cloud",lname:"web labss"};
const getAllDetails = getDetails.getFullName.call(cloudWeb);
console.log(getAllDetails);

In above example i have called getFullName method with cloudWeb arguments.

Thank you.

Blog Catagory : Blog , JAVASCRIPT