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

javascript - Hide toolbar of pdf file opened inside iframe using firefox -

Copy range with conditional formatting -

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