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
  • 7,910
  • 10
  • 36
  • 60

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
  • 95,740
  • 9
  • 109
  • 159