Take a look into the below code and explain me why it returns undefined
rather than the variable.
function aaa() {
return
{
test: 1
};
}
console.log(aaa());
Take a look into the below code and explain me why it returns undefined
rather than the variable.
function aaa() {
return
{
test: 1
};
}
console.log(aaa());
That's because of the new line at the end of return
(Automatic Semicolon Insertion).
Try:
function aaa() {
return {
test: 1
};
}
console.log(aaa());
Because you made a newline:
function aaa() {
return {
test: 1
};
}
console.log(aaa());