JavaScript learning
30/04/2015
cheatsheet
1. Function and Variable
a. Declare function
b. Declare variable
c. Reuse method
#2. Object a. Make an object
b. Make constructor of an object
c. Use constructor of an object
d. Use variables of an object
e. Private and public variables and function
private variables
are declared with thevar
keyword inside the object, and can only be accessed by private functions and privileged methods.private functions
are declared inline inside the object’s constructor (or alternatively may be defined via varfunctionName=function(){...})
and may only be called by privileged methods (including the object’s constructor).privileged methods
are declared withthis.methodName=function(){...}
and may invoked by code external to the object.public properties
are declared withthis.variableName
and may be read/written from outside the object.public methods
are defined byClassname.prototype.methodName = function(){...}
and may be called from outside the object.prototype properties
are defined byClassname.prototype.propertyName = someValue
static properties
are defined byClassname.propertyName = someValue
#3. Inheritance a.Inheritance object
#4. Notes
- Keyword
this
, within a function, this refers to object which call the function.