10 Matching Annotations
- Sep 2016
-
github.com github.com
-
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!
-
-
addyosmani.com addyosmani.com
-
namespaced
dt.Namensraum
-
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
-
self-contained
function is i a private scope (dt. Anwendungsbereich) eg
(var test = "hihi")()
-
ounter variable is actually fully shielded from our global scope so it acts just like a private variable
var testModule = (function () { var counter = 0 })()
-
)();
function is in a set of parentheses. This is a useful construct when trying to hide variables from the parent namespace!
-
encapsulates
dt. einkapseln / verschachteln
-
instantiation
dt. Instanzierung
-
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.
-
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!
-