
str.padStart(targetLength [, padString]) str.padEnd(targetLength [, padString]) targetLength functions is the total length of the targetLength string. The second optional parameter padString is a string to supplement the source string. The default is a space. 'es8'.padStart(2); // 'es8' 'es8'.padStart(5); // ' es8' 'es8'.padStart(6, 'woof'); // 'wooes8' 'es8'.padStart(14, 'wow'); // 'wowwowwowwoes8' 'es8'.padStart(7, '0'); // '0000es8' 'es8'.padEnd(2); // 'es8' 'es8'.padEnd(5); // 'es8 ' 'es8'.padEnd(6, 'woof'); // 'es8woo' 'es8'.padEnd(14, 'wow'); // 'es8wowwowwowwo' 'es8'.padEnd(7, '6'); // 'es86666' 
Object.values method returns an array of the enumerated properties of the passed object in the same order that the for in loop provides. Object.values(obj) obj parameter is the source object for the operation. This can be an object or an array (which is an object with such indices [10, 20, 30] -> {0: 10, 1: 20, 2: 30}). const obj = { x: 'xxx', y: 1 }; Object.values(obj); // ['xxx', 1] const obj = ['e', 's', '8']; // same as { 0: 'e', 1: 's', 2: '8' }; Object.values(obj); // ['e', 's', '8'] // , // const obj = { 10: 'xxx', 1: 'yyy', 3: 'zzz' }; Object.values(obj); // ['yyy', 'zzz', 'xxx'] Object.values('es8'); // ['e', 's', '8'] 
Object.entries method returns an array of the enumerated properties of the passed object in pairs [, ] in the same order as Object.values . const obj = { x: 'xxx', y: 1 }; Object.entries(obj); // [['x', 'xxx'], ['y', 1]] const obj = ['e', 's', '8']; Object.entries(obj); // [['0', 'e'], ['1', 's'], ['2', '8']] const obj = { 10: 'xxx', 1: 'yyy', 3: 'zzz' }; Object.entries(obj); // [['1', 'yyy'], ['3', 'zzz'], ['10': 'xxx']] Object.entries('es8'); // [['0', 'e'], ['1', 's'], ['2', '8']] 
getOwnPropertyDescriptors method returns descriptors of the own properties of the specified object. A property descriptor of its own is one that is defined directly on the object, and not inherited from its prototype. Object.getOwnPropertyDescriptor(obj, prop) obj is the source object and prop is the name of the property whose handle you want to get. Possible keys as a result: configurable, enumerable, writable, get, set and value . const obj = { get es8() { return 888; } }; Object.getOwnPropertyDescriptor(obj, 'es8'); // { // configurable: true, // enumerable: true, // get: function es8(){}, // // set: undefined // } 
SyntaxError ) when we added a comma at the end of the list: function es8(var1, var2, var3,) { // ... } es8(10, 20, 30,); { x: 1, } and array literals [10, 20, 30,] .async function declaration defines an asynchronous function that returns an AsyncFunction object. The internal structure of asynchronous functions works like generators, but they are not translated into generator functions. function fetchTextByPromise() { return new Promise(resolve => { setTimeout(() => { resolve("es8"); }, 2000); }); } async function sayHello() { const externalFetchedText = await fetchTextByPromise(); console.log(`Hello, ${externalFetchedText}`); // Hello, es8 } sayHello(); sayHello will output Hello, es8 in 2 seconds. console.log(1); sayHello(); console.log(2); 1 //
2 //
Hello, es8 // 2
async function always returns a promise and the await keyword can only be used in functions with the async .
SharedArrayBuffer constructor and the Atomics object with static methods.Atomics object is a collection of static methods like Math , so we cannot call its constructor. Examples of static methods of this object:
const esth = 8; helper`ES ${esth} is `; function helper(strs, ...keys) { const str1 = strs[0]; // ES const str2 = strs[1]; // is let additionalPart = ''; if (keys[0] == 8) { // 8 additionalPart = 'awesome'; } else { additionalPart = 'good'; } return `${str1} ${keys[0]} ${str2} ${additionalPart}.`; } esth equal to 7 will return → ES 7 is good.
Source: https://habr.com/ru/post/332900/
All Articles