-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[] ES8

, 12 2017 . 09:21 +
EcmaScript.

image

EcmaScript 8 EcmaScript 2017 TC39 . , EcmaScript . . ES6 2015, ES7 2016, - , ES5? 2009 , JavaScript.

, JavaScript, ES8 .

ES2017 (the 8th edition of the JavaScript Spec) was officially released and published yesterday! https://t.co/1ITn5bzaqj

Kent C. Dodds (@kentcdodds) June 28, 2017


, web PDF . ES8 .


String: padStart padEnd. , , . .
:

str.padStart(targetLength [, padString])
str.padEnd(targetLength [, padString])


, targetLength . padString . .

'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'


image

Object.values Object.entries


Object.values , for in.
:

Object.values(obj)


obj . ( [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']


image

Object.entries [, ] , 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']]


image

Object.getOwnPropertyDescriptors


getOwnPropertyDescriptors . , , .
:

Object.getOwnPropertyDescriptor(obj, prop)


obj prop , . : configurable, enumerable, writable, get, set value.

const obj = { get es8() { return 888; } };
Object.getOwnPropertyDescriptor(obj, 'es8');
// {
//   configurable: true,
//   enumerable: true,
//   get: function es8(){}, //  
//   set: undefined
// }


, .

image


(SyntaxError) :

function es8(var1, var2, var3,) {
  // ...
}


, :

es8(10, 20, 30,);


{ x: 1, } [10, 20, 30,].


async function , AsyncFunction. , .

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 Hello, es8 2 .

console.log(1);
sayHello();
console.log(2);


:

1 //
2 //
Hello, es8 // 2


, .

, async function await async.

image



, . , , . SharedArrayBuffer Atomics .

Atomics Math, . :
  • add / sub /
  • and / or / xor Ȼ / Ȼ / Ȼ
  • load


image

ES9



(ES6) , - .

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}.`;
}


-> ES 8 is awesome.
esth 7 -> ES 7 is good.

, \u \x. ES9 . MDN TC39.

image


JavaScript , . . TC39 . Typescript, , .
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/332900/

:  

: [1] []
 

:
: 

: ( )

:

  URL