arrays - Javascript function returning the function itself? -
i have small bit of code giving me headache. needs location (in case array representing longitude , latitude).
planner.js:
var plan = function (lawnmower, yard) { var currentpos = lawnmower.position; alert(currentlong);
lawnmower:
var longitude = homelongitude, latitude = homelatitude; var getposition = function() { return [longitude, latitude]; }; that.position = getposition;
when alert gets called returns getposition after equal sign.
heres pic
i'm novice @ js.
you forgot ()
when call getposition
, instead of assigning result that.position
you're assigning entire function:
that.position = getposition(); //parenthesis!
Comments
Post a Comment