Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
why change() in constructor is not defined,it should be acessed through __proto__ link in p.__proto__?

why change() in constructor is not defined,it should be acessed through proto link in p.proto? why change() in constructor is not defined,it should be acessed through proto link in p.proto? why change() in constructor is not defined,it should be acessed through proto link in p.proto? why change() in constructor is not defined,it should be acessed through proto link in p.proto?

//the first change() is not defined ,why
class Person {
  constructor() {
    console.log(this)
    console.log(this.__proto__)
    // change()//output:is not define
  }
  
  change() {
    console.log(this)
  }
}

var p = new Person()
Object.prototype.change = function() {
  console.log(' change in prototype')
}
change() //output:change in prototype

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try calling it with this keyword.

    //the first change() is not defined ,why
class Person
   {
       constructor()
       {
           console.log(this)
           console.log(this.__proto__)
           this.change()//output:is not define
       }
       change()
       {
           console.log(this)
       }

   }
 
    var p =new Person()
    Object.prototype.change=function()
    {
        console.log(' change in prototype')
    }
    change()//output:change in prototype

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!