Index ¦ Archives


This is my personal Javascript Reference and Cookbook.



abstract  arguments   boolean   break   byte
case  catch   char  class*  const
continue  debugger  default   delete  do
double  else  enum*   eval  export*
extends*  false   final   finally   float
for   function  goto  if  implements
import*   in  instanceof  int   interface
let   long  native  new   null
package   private   protected   public  return
short   static  super*  switch  synchronized
this  throw   throws  transient   true
try   typeof  var   void  volatile
while   with  yield

The && operator produces the value of its first operand if the first operand is falsy. Otherwise, it produces the value of its second operand.

The || operator can be used to fill in default values, e.g. var status = flight.status || "unkown"

The falsy values are false, null, undefined, empty string, 0, Nan

for in enumerates the property names/keys of an object. On each iteration, another property name string from the object is assigned to the variable. It is usually necessary to test object.hasOwnProperty(variable) to determine whether the peopery name is truly a member of the object or was instead on the prototype chain.

for (myvar in obj){ if (obj.hasOwnProperty(myvar){ ... }) }

Creating Objects Using Object Literals

Using Object.create() see.

Using the new keyword

Design Patterns

  • Object Literal Pattern
  • Revealing Module Pattern
  • Pubsub Pattern
  • Classical Inheritance and OOP

© Imran Nazir. Built using Pelican. Theme by Giulio Fidente on github.