What is the point of declaring variables without assignment?

I am studying some CreateJS samples, and in one of them I saw this, and I wonder what to use it for

(function() {
    var c = createjs;
    var a = function(blabla) {
        this.blabla = blabla;

    var p = Game.prototype;
    p.a;
    p.b;
    p.c;
    p.d;
    /*
    ... 15 variables like that ...
    */
    p.init = function(param) {
        /* blabla */
    }
    /*
    ...
    long code after that
    ...
    */
})();

In github samples, the directory /createjs/sandbox-master/PlanetaryGarycontains the filejs/Game.js

+4
source share
3 answers

I am the author of the original code. This template comes down to a simple philosophy that good code is self-documenting.

It is worth paying attention to those who come to this blind that these properties are not really called a, b, c, etc. It is also worth mentioning that they are usually assigned a default value (although not in this particular case).

, "". , , , .

, .

/**
 * Docs for firstName here.
 **/
p.firstName = "default";

/**
 * lastName docs.
 **/
p.lastName = "default";

, , . . , -.

( ), .

+5

Game, p.a, p.b .. , , , p .

, , , p, - .

+4

, p , :

Object.defineProperty(p, 'a', { get: function() {
  window.universalConstant = 42;
  return p._a;
});

, . , , @PaulD.

+3

All Articles