Skip to content

Instantly share code, notes, and snippets.

@anselmdk
Last active December 20, 2016 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anselmdk/5f14f08b1978be65945d to your computer and use it in GitHub Desktop.
Save anselmdk/5f14f08b1978be65945d to your computer and use it in GitHub Desktop.
JavaScript Cheat Sheet

ES6 Classes

Parent:

class Parent {
  constructor(vars) {
    //doing some grown up stuff
  }
}
export default Parent;

Child:

class Child extends Parent {
  constructor(vars) {
    super(vars);
    //doing some child stuff
  }
}

export default Child;

JavaScript Cheat Sheet

Timeout

setTimeout(function(){ alert("Hello"); }, 3000);

Looping

//arrays
arr.map(function(obj){ 
  console.log(obj);
});
//objects
Object.keys(obj).map(function(value, index) {
   console.log(obj[value])
});
//or
for(var key in obj) {
    if(obj.hasOwnProperty(key)) {
        console.log(obj[key]);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment