Consider the following case:
function func1() {
return {
hello: "world"
};
}
function func2() {
return
{
hello: "world"
};
}
console.log(func1());
console.log(func2());
The first function func1()
will return the object { hello: "world" }
but the second function func2()
will return undefined
. Why is that? My guess is the returned value needs to be on the same line as the return
keyword. What "rule" am I unaware of here?