why show "Undefined" below "Hello World"?
let Object_A = {};
Object_A.Func_01 = function() {
console.log("Hello World");
}
console.log(Object_A.Func_01());
why show "Undefined" below "Hello World"?
let Object_A = {};
Object_A.Func_01 = function() {
console.log("Hello World");
}
console.log(Object_A.Func_01());
It's because by saying console.log(object.function())
you are printing the return value of the function (which is undefined
because you haven't returned anything specifically). If you want to just print the hello word it's enough to call the function object.function()
cause it is already doing that.