I'm reading underscore.js sources, trying to understand all of it. The thing I don't yet understand is the definition of _
object. It's source is:
var _ = function(obj) {
if (obj instanceof _) return obj;
if (!(this instanceof _)) return new _(obj);
this._wrapped = obj;
};
In the actual scope (an iife), this refers to the global object and _
has not yet been declared yet.
If you type _
and hit enter in a console (e.g. chrome), assuming you've loaded underscore lib, you'll get the same function definition as above. Well - what is it for? Why isn't it just a normal object {}
with all functions/attributes attached as properties?