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
typeof 123; | |
// → 'number' | |
typeof 123n; | |
// → 'bigint' |
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
1234567890123456789n * 123n; | |
// → 151851850485185185047n ✅ |
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
1234567890123456789 * 123; | |
// → 151851850485185200000 ❌ |
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
BigInt(Number.MAX_SAFE_INTEGER) + 2n; | |
// → 9_007_199_254_740_993n |
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
max + 2; | |
// → 9007199254740992 ❌ |
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
max + 1; | |
// → 9007199254740992 |
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 max = Number.MAX_SAFE_INTEGER; | |
// → 9007199254740991 |
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
Tesla.prototype = Object.create(Car.prototype); | |
Object.defineProperty(Tesla.prototype, ‘constructor’, {value: Tesla, enumerable: false}); | |
Tesla.prototype.charge = function() { | |
console.log("Charging..."); | |
} | |
const tesla = new Tesla('3', 20); | |
tesla.drive(); | |
tesla.charge(); |
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 Tesla(model, chargetime) { | |
Car.call(this, 'Tesla', model); | |
this.chargetime = chargetime; | |
} |
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
Car.prototype.drive = function() { | |
console.log("Zoom!"); | |
} | |
const tesla = new Car('Tesla', '3'); | |
tesla.drive(); |