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

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -