Type of function

var foo = { bar: function() { return this.baz; }, baz: 1 };
console.log(typeof(f = foo.bar)());

sir why is this coming undefined not function

@aggarwalanshul01 why are you calling it, remove that and it will show type of f which is the typeof foo.bar i.e. function

var foo = {
  bar: function() {
    return this.baz;
  },
  baz: 1
}
console.log(typeof(f = foo.bar))
console.log((f = foo.bar)())

second console.log gives undefined, because f doesn’t have baz to return, hence it is returning undefined