Skip to content

Instantly share code, notes, and snippets.

View Hydrock's full-sized avatar

Alex Vechkanov Hydrock

View GitHub Profile
@Hydrock
Hydrock / gist.js
Created June 11, 2018 02:59
bigint_typeof
typeof 123;
// → 'number'
typeof 123n;
// → 'bigint'
@Hydrock
Hydrock / test.js
Created June 11, 2018 02:50
example_bigint_true
1234567890123456789n * 123n;
// → 151851850485185185047n ✅
@Hydrock
Hydrock / test.js
Created June 11, 2018 02:43
example-numbers-false
1234567890123456789 * 123;
// → 151851850485185200000 ❌
BigInt(Number.MAX_SAFE_INTEGER) + 2n;
// → 9_007_199_254_740_993n
max + 2;
// → 9007199254740992 ❌
max + 1;
// → 9007199254740992
const max = Number.MAX_SAFE_INTEGER;
// → 9007199254740991
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();
function Tesla(model, chargetime) {
Car.call(this, 'Tesla', model);
this.chargetime = chargetime;
}
Car.prototype.drive = function() {
console.log("Zoom!");
}
const tesla = new Car('Tesla', '3');
tesla.drive();