Shallow vs Deep Cloning

// shallow clone/copy:
let arr2 = [].concat(arr1);
let arr3 = [...arr1];
let obj2 = Object.assign({}, obj1); 
let obj3 = {...obj1};

// deep clone/copy
let obj2 = JSON.parse(JSON.stringify(obj1)); // old approach
let obj3 = structuredClone(obj1); // new approach

Equality Tables

== (negated: !=)

When using two equals signs for JavaScript equality testing, some funky conversions take place.

{{ keys[index1] }}
 
{{key}}

=== (negated: !==)

When using three equals signs for JavaScript equality testing, everything is as is. Nothing gets converted before being evaluated.

{{ keys[index1] }}
 
{{key}}

A standard IF statement. If(value) {/*- green -*/} else { /*- white -*/ }

Note: This row does not match up with any of the rows in the other table.

{{ key }}
 
if ({{ key }}) { /* {{ values1[index] ? 'executes' : 'does not execute' }} */ }



How to pick JS Frameworks?



Start time: 01:05
End time: 02:50

Fetch API

fetch(url)
.then(data => data.json())
.then(data => { console.log(data); })
.catch(error => alert(error));

Type Conversions in JS

Original
Value
Converted
to Number
Converted
to String
Converted
to Boolean
false 0 "false" false
true 1 "true" true
0 0 "0" false
1 1 "1" true
"0" 0 "0" true
"000" 0 "000" true
"1" 1 "1" true
NaN NaN "NaN" false
Infinity Infinity "Infinity" true
-Infinity -Infinity "-Infinity" true
"" 0 "" false
"20" 20 "20" true
"twenty" NaN "twenty" true
[ ] 0 "" true
[20] 20 "20" true
[10,20] NaN "10,20" true
["twenty"] NaN "twenty" true
["ten","twenty"] NaN "ten,twenty" true
function(){} NaN "function(){}" true
{ } NaN "[object Object]" true
null 0 "null" false
undefined NaN "undefined" false