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

195
Views
Call Method of JavaScript Not Returning Correct Value

const flightName = {
  airline: 'luftansa',
  itaCode: 'LH',
  book: function(flightname, text) {
    console.log(`This is ${flightname},${text}`);
  }
}

flightName.book('indigo', 'johnny');

let book1 = flightName.book;

book1.call('Johnny', 'King');

Output:

This is indigo,johnny

This is King,undefined
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try this

const flightName ={

airline: 'luftansa',

itaCode: 'LH',

book: function(flightname,text)
{

console.log(`This is ${flightname},${text}`);
}

}

flightName.book('indigo','johnny');

let book1 = flightName.book;

book1.call(this, 'Johnny','King'); 

about 4 years ago · Juan Pablo Isaza Report

0

you are calling your call funciton inccorect, call function is not supposed to work that way, as document stated: you should use it in this manner:

call()
call(thisArg)
call(thisArg, arg1)
call(thisArg, arg1, arg2)

so you need to change your code to:

book1.call(flightName,'johny', 'king');
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!