Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Be wary of anything claiming to be "Pro" whatever. I haven't read the book, but my take on the code is as follows:</p> <pre><code>&gt; var Class = (function() { &gt; &gt; // Constants (created as private static attributes). </code></pre> <p>The word "attributes" is wrong, it should be either "properties" or "variables" because they are variables, which can also be described as properties of the local activation/variable object.</p> <pre><code>&gt; var UPPER_BOUND = 100; &gt; &gt; // Privileged static method. &gt; this.getUPPER_BOUND() {//sic </code></pre> <p>The code will be executed in a global context where <code>this</code> is the window/global object. So <strong>if</strong> there is a global *getUPPER_BOUND* function, it will be called with no arguments. It is followed by a curly brace ({) which opens a block in a place where a block can't be, so that is a syntax error. </p> <p>I presume the following was intended:</p> <pre><code> this.getUPPER_BOUND = function() { </code></pre> <p>which creates a getUPPER_BOUND property of the global/window object that is assiged the anonymous function on the RHS when the code is run.</p> <pre><code>&gt; return UPPER_BOUND; } &gt; &gt; ... &gt; &gt; // Return the constructor. &gt; return function(constructorArgument) { </code></pre> <p>This is the function that is assigned to the global variable "Class". </p> <pre><code>&gt; ... &gt; } &gt; })(); </code></pre> <p>With fixes it may "work", but not elegantly. Any book with such glaring errors in the code has not been carefully written and certainly hasn't been properly reviewed before being published.</p> <p>Use reputable online resources and continue to ask questions about anything you don't understand or think is in error. There are other forums for discussing javascript that can provide far more detailed answers for technical questions.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload