I am trying to get my head around how Javascript function behaves. Is it a function or an object or both?
Functions in javascript are first-class objects. So they're both functions and objects.
Because they are first class objects, you can assign a variable to a function and give it properties, eg:
var addName=function(){};
addName.blah = 1;
If they weren't first-class objects you'd be limited to this syntax but you can do it both ways:
function addName(){}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With