-3

why show "Undefined" below "Hello World"?

let Object_A = {};
Object_A.Func_01 = function() {
  console.log("Hello World");
}
console.log(Object_A.Func_01());
Rob Moll
  • 3,345
  • 2
  • 9
  • 15
Abu Talha
  • 9
  • 2

1 Answers1

0

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.

Jencel
  • 722
  • 7
  • 17