javascript - jQuery data() vs Objects (Performance) -
i wondering way more efficient using jquery data bind data object or using kind of object. trying create kind of model app. here object code
var persondata = function () { var = {}, _name = 0, _age = 0.0, _domid = false; that.data = initdata(); //this initing data options function initoptions () { return { name: _name, age: _age, domid: _domid } } that.setname = function (name) { that.data.name = name; } that.getname = function () { that.data.name; } // forgot add dom id, there id binding that.setdomelementid = function (id) { that.data.domid = id; } //add getters , setter return that; }
thanks opinions
by way there plugin generating getters , setters in textmate javascript
jquery's .data()
attaching data dom elements. if you're not touching dom, don't touch .data()
.
also, don't think kind of encapsulation you're going worthwhile in javascript (unless require detect data read/writes). especially if you're concerned performance, directly accessing objects' properties better option. javascript dynamic language, embrace :)
Comments
Post a Comment