इन दो कार्यों पर विचार करें।जावास्क्रिप्ट में ब्रेसिज़ की स्थिति क्यों है?
function func1() {
return
{
foo: 'bar'
}
}
function func2() {
return {
foo: 'bar'
}
}
alert(typeof func2()) //return object
alert(typeof func1()) //return undefined
क्यों जब कई अन्य भाषाओं में ऐसा नहीं होता है ब्रेसिज़ की स्थिति फर्क पड़ता है? क्या यह एक भाषा सुविधा या एक बग है?
यह [12.9 रिटर्न स्टेटमेंट] (http://www.ecma-international.org/ecma-262/5.1/#sec-12.9) के लिंक द्वारा सुधार किया जाएगा [ईजे ने बताया] (http: //stackoverflow.com/questions/24120708/why-does-the-position-of-braces-in-javascript-matter#comment37213016_24120708)। –
जेएस संकलित नहीं करता है। – Scimonster