ES6 Tutorial - #6 Default Params & Template Strings

preview_player
Показать описание
00:56 Falsy comparison (ES5, pre-ES6)
01:39 Default Parameters (ES6)
02:46 'arguments' caveat
05:20 Default values with object destructuring
07:48 Default values with array destructuring
09:43 Template Strings / Literals
13:00 String Interpolation

Prior to ES6, if you needed a default value for a function parameter, you'd either perform a typeof check against undefined, or rely on a falsy comparison with the '||' (OR) operator. It's now much more intuitive with default params, and those can also be used in destructuring. With template literals, not only do they allow for multi-line strings, but also interpolation, meaning evaluating placeholders and replacing them with corresponding values. Awesome stuff!

Рекомендации по теме