You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
ES5-ES6-ES2017-ES2019 omit & pick � r�U P{)r�U omit-es2015.js ��gr�U � r�U Object.keys(obj) .filter((key) => ['blacklisted', 'keys'].indexOf(key) < 0) .reduce((newObj, key) => Object.assign(newObj, { [key]: obj[key] }), {}) omit-es2017.js �Kr�U �zr�U Object.entries(obj) .filter(([key]) => !['blacklisted', 'keys'].includes(key)) .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {}
技術書同人誌博覧会(技書博)向けのNode.js同人誌を書いてる際に、オススメのサイトを見つけたのでご紹介します。 @flaviocopesさんの「THE ES Guide」です。 ES2015(ES6) ES2015はlet・const・class・Promiseをはじめとする重要な構文や機能が目白押しなので、とても重要度が高いです。 flaviocopes.com Arrow Functions A new this scope Promises Generators let and const Classes Constructor Super Getters and setters Modules Importing modules Exporting modules Template Literals Default parameters The spread operator
はじめに 現場での業務でJavaScriptを使用しているのですが、昔からあるシステムの改修でJavaScriptのバージョンがES2015を使って仕事しています。ES2015ではasync/awaitは使用できないため他の方法で代用しました。他現場でも使用するかもしれないので、備忘録としてメモ程度に残しておきます。 ソースコード // setTimeoutを使用して、非同期処理にする(実際はDB処理などを行う) // 引数として渡された値(秒数)を待機時間とし値を出力 function promiseFunc(timeoutSeconds) { return new Promise((resolve, reject) => { const timer = setTimeout(() => { clearTimeout(timer); console.log(timeoutSeconds)
async/await前提のライブラリ(例:Puppeteer)を使っていると、awaitをネストしたくなることがあります。例えば次のような状況です。 const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); class Foo { async getBar() { console.log('getBar()'); return new Promise(resolve => resolve(new Bar())); } } class Bar { async baz() { console.log('baz()'); await sleep(5000); console.log('baz finished'); } } (async () => { const foo = new Foo(); await (a
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く