Show Menu
Cheatography

Basic Javascript Cheat Sheet (DRAFT) by

A cheat sheet covering basic syntax, keywords, and javascript structure.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Common Javascript Object Sytnax

Obj: Literal Notation
var x = { proper­ty1­:"so­mev­alu­e", proper­ty2­:"so­mev­alu­e" };
Obj: Constr­uctor Notation
var x = new Object(); x.prop­erty1 = "­som­eva­lue­"; x.prop­erty2 = "­som­eva­lue­";
Obj: Dot notation
obj.myProp (gets value of myProp)
Obj: Bracket notation
obj["my­Pro­p"] (gets value of property in the string)
Method: Literal notation
method: functi­on(­par­am)­{...}
Method: Dot notation
obj.method = functi­on(­par­am)­{...};
New Obj Class
function Name(p­ara­m){....}
List Obj Properties
for (var proper­tyName in obj) { ... }

Copying an Object

function clone() {
var objectCopy = {};
for (var x in card1){
object­Copy[x] = card1[x];
}
return object­Copy;
}