0
function ok(){

return 
   { 
     home : "OK"
    };

}

when i code like this the function will return undefined

enter image description here

but if i just shift the { it starts working

function ok(){

return { 
     home : "OK"
    };

}

enter image description here

Is this somekind of auto adding ';' at the end of line ?

Atul Sharma
  • 9,397
  • 10
  • 38
  • 65

1 Answers1

2

Javascript engines insert semicolons at certain newline positions. So, your first code is really this:

return; 
    { 
       home : "OK"
    };

And it returns nothing.

Gerardo Furtado
  • 100,839
  • 9
  • 121
  • 171