/ Published in: JavaScript
jsHint happy class template for javascript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/*jshint browser:true, jquery:true, undef:true, devel:true, unused:false, curly:true, strict:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, quotmark:true, indent:2, maxerr:50 */ /*global window:true */ /** Global Class collection with a class(klass) object with private and public variables/methods without using this. @author John Doe @namespace classLib */ (function (window) { 'use strict'; var classLib = window.classLib || {}; /** @class klass @namespace classLib */ classLib.klass = function () { /* Private variables */ var _foo, _bar; _foo = 'foo'; _bar = 'bar'; /*-------------------------------------------------------*/ /* Private functions */ var _privateFunc = function () { _foo = _bar; }; return { /* Public functions */ init: function () { privateFunc(); }, getFoo: function () { return _foo; }, setFoo: function (value) { _foo = value ||Â _foo; } }; }(); // Expose klass to the global object window.classLib = classLib; }(window));