इसके लिए "इस" कीवर्ड का प्रयोग करें।
उदाहरण
निम्नलिखित कोड है -
class Employee {
constructor() {
this.tempObject = [
{
firstName: "David",
setTheAnotherFirstName() {
this.firstName = "Carol";
},
},
];
}
}
var empObject = new Employee();
empObject.tempObject[0].setTheAnotherFirstName();
console.log("The Change First Name is=" + empObject.tempObject[0].firstName); उपरोक्त प्रोग्राम को चलाने के लिए, आपको निम्न कमांड का उपयोग करने की आवश्यकता है -
node fileName.js.
यहाँ, मेरी फ़ाइल का नाम है demo220.js.
आउटपुट
आउटपुट इस प्रकार है -
PS C:\Users\Amit\JavaScript-code> node demo220.js The Change First Name is=Carol