Upgrade to Pro — share decks privately, control downloads, hide ads and more …

社内LT2020/01/23

 社内LT2020/01/23

Kento Matsumoto

January 23, 2020
Tweet

More Decks by Kento Matsumoto

Other Decks in Programming

Transcript

  1. String.prototype.matchAll const regexp = /t(e)(st(\d?))/g const str = 'test1test2' [...str.matchAll(regexp)]

    // ['test1', 'e', 'st1', '1', index: 0, input: 'test1test2', length: 4] // ['test2', 'e', 'st2', '2', index: 5, input: 'test1test2', length: 4]
  2. import() import { calcAge } from '..utils' calcAge('1989/12/05') // 30

    const utils = await import('..utils') utils.calcAge('1989/12/05') // 30
  3. BigInt const int = Number.MAX_VALUE // 1.7976931348623157e+308 const bigInt =

    Number.MAX_VALUE //  1797693134862315708145274237317043567980705675258449965989174768031572 607800285387605895586327668781715404589535143824642343213268894641827684 675467035375169860499105765512820762454900903893289440758685084551339423 045832369032229481658085593321233482747978262041447231687381771809192998 81250404026184124858368 n
  4. Promise.allSettled const int = promises = [ fetch('index.html'), fetch('test.html') ]

    const result = await Promise.allSettled(promises) const successfulPromises = result.filter(p.status=== 'fulfilled')
  5. for-in mechanics - Partially specifying object enumeration order in JavaScript

    (順序が部分的に指定されるようになる)
  6. Optional Chaining const obj = {} if (!obj.address.postCode) console.log('OK') //

    Uncaught TypeError: Cannot read property 'postCode' of undefined if (!(obj && obj.address && obj.address.postCode)) console.log('OK') // OK if (!obj?.address?.postCode) console.log('OK') // OK
  7. Nullish coalescing Operator Null || 'second' // 'second' Null ??

    'second' // 'second' undefined || 'second' // 'second' undefined ?? 'second' // 'second' 0 || 'second' // 'second' 0 ?? 'second' // 0 '' || 'second' // 'second' '' ?? 'second' // ''
  8. References - https://github.com/tc39/proposals/blob/master/finished-proposals.md - https://github.com/tc39/proposal-string-matchall - https://github.com/tc39/proposal-dynamic-import - https://github.com/tc39/proposal-bigint -

    https://github.com/tc39/proposal-promise-allSettled - https://github.com/tc39/proposal-global - https://github.com/tc39/proposal-for-in-order - https://github.com/tc39/proposal-optional-chaining - https://github.com/tc39/proposal-nullish-coalescing