I have an iife & a inner function.The inner function is returning an object in first case the {
is immediately after the return
keyword, in second case the brace {
starts in a new line. In fist case the value is correctly returned and in second case it is throwing an undefined
error
(function() {
function sayHello() {
var name = "myName";
return {
fullName: name
}
}
console.log(sayHello().fullName);
})();
(function() {
function sayHello() {
var name = "myName";
return
{
fullName: name
}
}
console.log(sayHello().fullName);
})();
I am not able to understand the effect statement in a new line after return
statement & I am only guessing the return statement is getting terminated even though there is a statement in next line