This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const EXTENSION_TYPE = { | |
| 0x01: 'PlainText', | |
| 0xF9: 'GraphicControl', | |
| 0xFE: 'Comment', | |
| 0xFF: 'Application' | |
| }; | |
| /** | |
| * Returns total length of data blocks sequence | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Account { | |
| pay(orderPrice) { | |
| if (this.canPay(orderPrice)) { | |
| console.log(`Paid ${orderPrice} using ${this.name}`); | |
| } else if (this.incomer) { | |
| console.log(`Cannot pay using ${this.name}`); | |
| this.incomer.pay(orderPrice); | |
| } else { | |
| console.log("Unfortunately, not enough money"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Engine2 { | |
| simpleInterface() { | |
| console.log("Engine 2.0 - tr-tr-tr"); | |
| } | |
| } | |
| class EngineV8 { | |
| complecatedInterface() { | |
| console.log("Engine V8! - wroom wroom!"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function bmwProducer(kind) { | |
| return kind === "sport" ? sportCarFactory : familyCarFactory; | |
| } | |
| function sportCarFactory() { | |
| return new Z4(); | |
| } | |
| function familyCarFactory() { | |
| return new I3(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // use computed property names when creating objects with dynamic property names. | |
| function getKey(k) { | |
| return `a key named ${k}`; | |
| } | |
| // bad | |
| const obj = { | |
| id: 5, | |
| name: 'San Francisco', | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // will return a random color from the array | |
| const colors = [ | |
| "blue", | |
| "white", | |
| "green", | |
| "navy", | |
| "pink", | |
| "purple", | |
| "orange", | |
| "yellow", |