How to pass variables to other functions inside object in javascript -


var mycar2 = {      maxspeed: 70,     driver: "arnold",      drive: function(speed, time) {         console.log("speed " + (speed * time));     },      logbook: function(a , b) {               console.log("max speed " + this.maxspeed + " " + this.drive(a , b));     } };  mycar2.logbook(3 , 6); 

if run code this.drive(a , b) undefined. how can pass variables drive() function using logbook()?

you passing variables drive, , defined within it. if weren't wouldn't speed 18 in output, speed nan.

the undefined value return value of drive, because haven't put return statement in function.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -