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?
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?
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