Avoiding the "this" Keyword in Javascript

I don't like the keyword "this" in JS. I never use it. I got the idea from watching Douglas Crockford presentations. I also never use classes in JS; they are pointless to me. Here's a couple of examples of how I do things without classes and without the use of "this".

(function($) {
 
  /**
   * Example of thing that returns a boolean without using the "this" keyword.
   */
  var ThingThatReturnsBoolean = (function() {
    // Sets up the variable that will be returned.
    var BooleanToReturn = false;
    // Creates a private variable.
    var APrivateVariable = 3;
    // A private function.
    var APrivateFunction = function() {
      // Code...
    };
    // A private Object.
    var APrivateObject = {};
 
    // More private code which could change BooleanToReturn or APrivateObject...
 
    return BooleanToReturn;
  })();
 
  /**
   * Example of returning an object without using the "this" keyword.
   */
  var ThingThatReturnsAnObject = (function() {
    // Initializes an object to return.
    var ObjectToReturn = {
      someProperty: '',
      someOtherProperty: {}
    };
 
    // Adds a new property to the object.
    ObjectToReturn.someNewThing = 'new thing';
 
    // More private code which could extend ObjectToReturn...
 
    return ObjectToReturn;
  })();
 
})(jQuery);

Article Type

General