I've generally built a JavaScript file for each "class" I want to build. So, each class would look something like:
Person.js
Having a class like this gives me the opportunity to do something like:Code:function Person() { var self = this; // variables this.XmlRequestPerson; // methods this.loginPerson = loginPerson; function loginPerson(userName, password) { // do some stuff! } }
Are there better ways to do this? It just seems like the "var self = this" thing is stupid, because inside the Person.js file I have to reference everything local by "self" instead of "this". Thoughts??Code:var person = new Person(); person.loginPerson("sup", "dude");




Bookmarks