Cheatography
https://cheatography.com
My Javascript notes, stuff that I use often in the curent project I'm working on
For looplet iterable = [1, 2, 3];
for(let value of iterable) { console.log(value); } |
Slice VS Spliceslice | shallow | splice | changes |
The slice() method retrurns a shallow copy of a portion of an array into a new array object:
arr.slice([begin[, end]])
The splice method changes the content of an array by removing existing elements and/or adding new elements.
arr.splice(start, deleteCount [, item1 [, item2 ...]])
Chomp stringstring = string.slice(0, -1);
|
Strings: substr VS substringstring.substr(start, length) | string.substring(start, stop) |
| | Cloning/AssignmentObject.assign(obj1, obj2);
to clone:
let clone = Object.assign({}, obj1); // Though not sure if swallow or deep copy |
"Falsy" values in JSUndefined
| null
| false
| +0 , -0 , and NaN
| ""
|
| | Array aggregationarray1 = array1.concat(array2);
|
Case insensitive comparisson(a, b) => a.toLowerCase().localeCompare(b.toLowerCase())
|
|
Help Us Go Positive!
We offset our carbon usage with Ecologi. Click the link below to help us!
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by dimitrios