JavaScript

Resources

Type
MDN
Array
MDN
Date
MDN
Object
MDN
String
MDN
JSON
MDN
Set
MDN
RegExp
MDN
Destructuring Assignment
MDN
const
MDN
let
MDN
export
MDN

strict mode

Begin files with:
1
'use strict';
Copied!

Arrow functions: () => {}

1
const a = (param1, param2) => {
2
return param1 + param2;
3
4
}
5
6
const b = (param1, param2) => param1 + param2;
Copied!

String

UTF Support

window

window.location.hash

1
console.log(window.location.hash);
Copied!
Results:
1
#array
Copied!
Results will always be prefixed with #

scroll

Scroll to a part of the screen.
1
window.location.hash = '#object'
Copied!

trailing commas

Simple Assert

1
input = "a b c d e";
2
3
main(input) {
4
...
5
}
6
7
assert(expected, input) {
8
console.log(input);
9
actual = main(input);
10
result = expected === actual;
11
console.log(result);
12
if (!result) {
13
console.log(actual);
14
console.log(expected);
15
}
16
}
17
18
// Case 1
19
assert(expected, input);
20
21
// Case 2
22
assert(expected2, input2);
23
24
// Case 3
25
assert(expected3, input3);
Copied!
Warning: querystring.stringify does not stringify deeply nested objects.

Classes

1
class Animal {
2
constructor() {
3
}
4
}
5
6
class Cat extends Animal {
7
constructor(props) {
8
super(props)
9
}
10
}
Copied!

Flow vs TypeScript

Flow

ESLINT

Alternatives

Frameworks

ORM

Last modified 2yr ago