Telerik DevRel
Developer Relations team @ Telerik!
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
String.prototype.{trimStart,trimEnd}
.trim
.trimLeft
let tooMuchSpace = ' I need space. ';
//" I need space. "
console.log(JSON.stringify(tooMuchSpace.trimEnd()));
// " I need space."
console.log(JSON.stringify(tooMuchSpace.trimStart()));
// "I need space. "
console.log(JSON.stringify(tooMuchSpace.trim()));
// "I need space."
Symbol.prototype.description
let mySymbol = Symbol('#FrontZurich is great');
console.log(mySymbol);
// Symbol(#FrontZurich is great)
console.log(mySymbol.description);
// #FrontZurich is great
optional catch binding
try {
throw new Error('I know that already');
} catch (e) {
logMyErrors(e);
}
// w optional catch binding
try {
throw new Error('I know that already');
} catch {
}
Array.prototype.sort()
required to be stable
let sortA = [
{'name': 'a', 'age': 2 },
{'name': 'a', 'age': 1 },
{'name': 'c', 'age': 1 },
{'name': 'a', 'age': 3 },
{'name': 'b', 'age': 1 }
];
sorte.sort((a,b) => a.age - b.age);
// [
// {name: "a", age: 1}
// {name: "c", age: 1}
// {name: "b", age: 1}
// {name: "a", age: 2}
// {name: "a", age: 3}
// ]
@tzmanics | #FrontZurich
Array.prototype.{flat,flatMap}
.map.flat
let nested = [1, 2, [3, 4, [5, 6]], 7];
// (4) [1, 2, Array(3), 7]
nested.flat();
// (6) [1, 2, 3, 4, Array(2), 7]
nested.flat(2);
// (7) [1, 2, 3, 4, 5, 6, 7]
let arr = [1, 2, 3, 4];
arr.map(x => [x * x]);
// [[1], [4], [9], [16]]
arr.flatMap(x => [x * x]);
// [1, 4, 9, 16]
Object.fromEntries
Object.entries
let obj = {
key1: 'value 1',
key2: 'value 2',
key3: true
};
let entries = Object.entries(obj);
// (3) [Array(2), Array(2), Array(2)]
// 0: (2) ["key1", "value 1"]
// 1: (2) ["key2", "value 2"]
// 2: (2) ["key3", true]
let fromEntries = Object.fromEntries(entries);
//{key1: "value 1", key2: "value 2", key3: true}
Well-formed
JSON.stringify
Function.prototype.toString
JSON superset
revision
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
@tzmanics | #FrontZurich
By Telerik DevRel
Thankfully, every year ECMAScript gives us new shinies to advance how we code JavaScript. I’ve found myself digging into features & proposals ever since my curiosity of ES2017’s `SharedArrayBuffer` took me down a fascinating rabbit hole. Let’s delve into some of the features & proposals we get to look forward to in 2019.