= koa(); // generator app.use(function *(next){ // let block scope let start = new Date; // yield ඇಉظݺͼग़͠ΛݮΒͤΔ yield next; let ms = new Date - start; // template string literal this.set('X-Response-Time', `${ms}ms`); }); app.use(function *(next){ let start = new Date; yield next; let ms = new Date - start; console.log(`{this.method} {this.url} - ms`); }); ͜Μͳ෩ʹॻ͚Δ
this.name = name this.age = age } getInfo() { let name = this.name; let age = this.age; let nextAge = this.age + 1; // enhanced object literal return { name, age, nextAge }; } } // @@toStringTag ͚ͳ͍ͱ [object object] Person.prototype[Symbol.toStringTag] = "Person"; var alice = new Person('alice', 13); var bob = new Person('bob', 15); console.log('' + alice); console.log(bob.getInfo()); ͜Μͳ෩ʹॻ͚Δ