function foo() {
return
{
foo: 'bar'
}
}
function bar() {
return {
foo: 'bar'
}
}
typeof foo() === typeof bar(); //why this is false
I didnt get why typeof foo() === typeof bar() returing false
function foo() {
return
{
foo: 'bar'
}
}
function bar() {
return {
foo: 'bar'
}
}
typeof foo() === typeof bar(); //why this is false
I didnt get why typeof foo() === typeof bar() returing false
Because of the line break after return
, foo()
is equivalent to
function foo() {
return;
// ↑ note the semicolon
{
foo: 'bar'
}
}
and is returning undefined
.
On the other hand, bar()
is returning an object.