Show Menu

My JS notes Cheat Sheet by

My Javascript notes, stuff that I use often in the curent project I'm working on

For loop

let iterable = [1, 2, 3];
for­(let value of iterable) { consol­e.l­og(­value); }

Slice VS Splice

The slic­e() method retrurns a shal­low copy of a portion of an array into a new array object:­ice­([­begin[, end]])

The splice method chan­ges the content of an array by removing existing elements and/or adding new elements.
arr.sp­lic­e(s­tart, delete­Count [, item1 [, item2 ...]])

Chomp string

string = string.slice(0, -1);

Strings: substr VS substring­bst­r(s­tart, leng­th)­bst­rin­g(s­tart, stop)

Clonin­g/A­ssi­gnment­sig­n(obj1, obj2);
to clone:
let clone =­sig­n({}, obj1); // Though not sure if swallow or deep copy

"­Fal­sy" values in JS

+0, -0, and NaN

Array aggreg­ation

array1 = array1.concat(array2);

Array includes element


Case insens­itive compar­isson

(a, b) => a.toLowerCase().localeCompare(b.toLowerCase())

Logging companions


For something like:
consol­e.l­og(­'%cd[ o_0 ]b %s', 'color: #fa5732;', 'DATA');

Download the My JS notes Cheat Sheet

1 Page

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

Like this cheat sheet? Check out our sponsors! is a collection of tools to make your writing better. More readable content means higher conversion rates and better reader engagement. Measure website and document readability, measure keyword density and more!

Click Here To Get Started!



No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          AngularJS Cheat Sheet
          JavaScript Cheat Sheet
          jasmine JS testing Cheat Sheet

          More Cheat Sheets by dimitrios

          CoffeeScript Cheat Sheet
          vim.spf13 Cheat Sheet
          The 30 CSS Selectors You Must Memorize Cheat Sheet