javascript - What is _events and what is it used for? -
searching backbone see used 12 times , attached this
within of backbone.events.
is property of backbone.events? if why have underscore prefix?
what used for?
on: function(name, callback, context) { if (!(eventsapi(this, 'on', name, [callback, context]) && callback)) homecoming this; this._events || (this._events = {}); var list = this._events[name] || (this._events[name] = []); list.push({callback: callback, context: context, ctx: context || this}); homecoming this; },
the underscore meant indicate should treated private property. _events
map of event callbacks used backbone.events.
any property or method added javascript object public. underscore used convention show property/method not used outside of object.
here classic link explains bit: http://javascript.crockford.com/private.html
javascript backbone.js
No comments:
Post a Comment