Show Menu

My JS notes Cheat Sheet by

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

For loop

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

Slice VS Splice

slice
shallow
splice
changes
The slic­e() method retrurns a shal­low copy of a portion of an array into a new array object:
arr.sl­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

string.su­bst­r(s­tart, leng­th)
string.su­bst­rin­g(s­tart, stop)
 

Clonin­g/A­ssi­gnment

Object.as­sig­n(obj1, obj2);
to clone:
let clone = Object.as­sig­n({}, obj1); // Though not sure if swallow or deep copy

"­Fal­sy" values in JS

Undef­ined
null
false
+0, -0, and NaN
""
 

Array aggreg­ation

array1 = array1.concat(array2);

Array includes element

array1.includes('xyz')

Case insens­itive compar­isson

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

Logging companions

http:/­/1l­ine­art.ku­lao­ne.c­om/#/
http:/­/ba­da5­5.io/

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

Download the My JS notes Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/dimitrios_my-js-notes.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

Like this cheat sheet? Check out our sponsors!

Readable.io 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!

 

Comments

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