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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -