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 -

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

Why does a .NET 4.0 program produce a system.unauthorizedAccess error on a Windows Server 2012 machine with .NET 4.5 installed? -