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 -

excel vba - VBA Proxy auto-configuration for http requests -

php - phpWord - Tables with borders in headers/footers -