More at https://www.youtube.com/watch?v=2pL28CcEijU
Number.MAX_VALUE > 0;
Number.MIN_VALUE < 0;
1 < 2 < 3;
3 > 2 > 1;
42.toFixed(2);
42. toFixed(2);
42 .toFixed(2);
42 . toFixed(2);
42.0.toFixed(2);
42..toFixed(2);
[] == ![];
[] + {};
{} + [];
Number("");
Number(" ");
Number("\r\n\t");
Number("0");
Number("-0");
JSON.parse("-0");
- 0;
Number("- 0")
JSON.stringify(-0);
String(-0);
-0 + "";
Number("0.");
Number(".0");
Number(".");
Number(undefined);
Number(null);
Number("0O10");
Number("0X10");
Number("2O17");
Number({});
Number([]);
String({});
String([]);
String(null);
String([null]);
String(undefined);
String([undefined]);
String([null,null,]);
String([undefined,undefined,]);
String([,,]);
''``
/,/.test([,])
/,/.test([1,])
/,/.test([1,2])
Array(3);
[,,,]
a = [];
a.length = 3;
a;
[undefined,undefined,undefined]
[1,100000,30,21,4].sort()
let cats = [];
cats[30] = 'Dusty';
cats['foo'] = 'Bar';
cats.length; // ?
Object.keys(cats).length; // ?
Array(3).join("a");
Array(3).map(x => "a");
Array.apply(null, {length: 3})
Array.apply(null, [3])
Array.apply(null, Array(3))
Array.apply(null, [,,,])
Array.apply(null, () => {})
Array.call(null, 3)
'👨👩👧👦'.slice(2)
'💩💩💩'.split('')
[...'💩💩💩']
[...'👨👩👧👦']
o1 = {foo:1};
o2 = Object.create(null);
o2.foo = 1;
o1 + "";
o2 + "";
let a = 42;
switch (a) {
default:
a += 1;
case 44:
a += 2;
case 45:
a += 5;
break;
case 46:
a += 9;
break;
}
(() => {
try {
return 2;
}
finally {
return 3;
}
})();
(() => {
try {
return 2;
}
finally {
// return 3;
}
})();
(o => o)();
(() => {})();
(() => {return;})();
(() => undefined)();
(() => {return undefined})();
function *foo(){
try {
yeld 1;
yeld 2;
}
finally {
yeld 'finally';
}
yeld '?';
}
let it = foo();
it.next();
it.return();
it.next();
function *foo(){
yeld 1;
yeld 2;
return 3;
}
for (let i of foo()) {
console.log(i);
}
typeof a;
typeof b;
let b;
foo = (x = {y: 10}, {y = 20} = {}) => console.log(x.y, y);
foo();
foo({},{});
foo({y:30},{y40});
class Px {
foo() { console.log('Px:foo'); }
}
class Cx extends Px {
bar() { console.log('Cx:bar'); }
foo() { this.bar(); super.foo(); }
}
class Py {
foo() { console.log('Py:foo'); }
}
class Cy extends Px {
bar() { console.log('Cy:bar'); }
foo() { this.bar(); super.foo(); }
}
let x = new Cx();
let y = new Cy();
x.foo();
y.foo();
y.foo.call(x);
const obj = {
foo: 1,
bar: {
tar: true
}
}
Object.freeze(obj)
obj.foo = 2
obj.bar.tar = false
console.log(obj)
0 || 1
0 ?? 1
'' || 1
'' ?? 1
null || 1
null ?? 1
null > 0
null >= 0
null == 0