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

124
Views
how to pass this. variable to child function Javascript

The parent.age set to 20 so it will overwrite the "this.age = 5" of the parent function and then I want to pass this.age with the value of 20 to the child function so the console log output should be ( parent Age 20 )

function parent(){
this.age = 5 // this age will overwrite by 20 and then should be passed to the child function

function child(event){
console.log("parent Age", this.age) // <- the output should be "parent Age 20"
}

window.addEventListener('click',child)
} 


parent.age = 20
parent()

console.log(parent.age) // output ->  20

about 4 years ago · Juan Pablo Isaza
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!