10 Matching Annotations
  1. Sep 2016
    1. Reusing an object with a reset function is much faster than declaring a new object with new

      Better insert a reset function than declare a new object!

    1. namespaced

      dt.Namensraum

    2. var myNamespace = (function () {   var myPrivateVar, myPrivateMethod;   // A private counter variable  myPrivateVar = 0;   // A private function which logs any arguments  myPrivateMethod = function( foo ) {      console.log( foo );  };   return {     // A public variable    myPublicVar: "foo",     // A public function utilizing privates    myPublicFunction: function( bar ) {       // Increment our private counter      myPrivateVar++;       // Call our private method using bar      myPrivateMethod( bar );     }  }; })();

      Module Template

    3. self-contained

      function is i a private scope (dt. Anwendungsbereich) eg

      (var test = "hihi")()
      
    4. ounter variable is actually fully shielded from our global scope so it acts just like a private variable
      var testModule = (function () {
      var counter = 0
      })()
      
    5. )();

      function is in a set of parentheses. This is a useful construct when trying to hide variables from the parent namespace!

    6. encapsulates

      dt. einkapseln / verschachteln

    7. instantiation

      dt. Instanzierung

    8. Literals

      Als Literal (lateinisch littera ‚Buchstabe‘) bezeichnet man in Programmiersprachen eine Zeichenfolge, die zur direkten Darstellung der Werte von Basistypen (z. B. Ganzzahlen, Gleitkommazahlen, Zeichenketten) definiert bzw. zulässig ist.

    9. Car.prototype.toString = function () {  return this.model + " has done " + this.miles + " miles";};

      moving the toString() function out of the constructor! Why? otherwise its redefined every time the constructor is called see above!