1
function addOne(){
  // Anything
}

addOne // Output:f addOne(){...}

addOne.count = 0;

console.log(addOne.count, addOne); // Output: 0 and f addOne() {...}

So how come addOne is function as well as acts as an object?

Ivar
  • 6,138
  • 12
  • 49
  • 61
  • 1
    "*So how come addOne is function as well as acts as an object ?*" the obvious answer is...that functions are objects. The only special thing is that they are callable but are otherwise still just an object. – VLAZ Jan 04 '21 at 09:26
  • Every function in JavaScript is a Function object. – abhay Jan 04 '21 at 09:28

1 Answers1

0

That's because every function in JavaScript is an object. Take a look at this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions