Last active
June 16, 2023 16:50
-
-
Save rodukov/439a96d012ac23736b822d376c3b6b62 to your computer and use it in GitHub Desktop.
Senior JavaScript Things
This file contains 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 person1 = {"name": "Michael", age: 25} | |
const person2 = {"name": "Kate", age: 23 } | |
function log() { | |
console.log(this.name, this.age) | |
} | |
function bind(ctx, fn) { | |
return function(...args) { | |
fn.apply(context, args) | |
} | |
} |
This file contains 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 sleep = sec => new Promise(resolve => setTimeout(() => resolve(sec), sec*1000)) | |
sleep(3).then(sec => console.log(`Executed after ${sec} seconds`)) | |
/* Promise.all([sleep(1), sleep(2), sleep(3)]).then(data => console.log(data)) */ | |
/* Promise.race([sleep(1), sleep(2), sleep(3)]).then(data => console.log(data)) */ |
This file contains 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 injections to Object Global Class */ | |
Object.prototype.keyslength = () => Object.keys(s).length | |
Object.prototype.valueslength = () => Object.values(s).length | |
/* Custom injections to custom object */ | |
const keyslength = () => Object.keys(s).length | |
const valueslength = () => Object.values(s).length | |
let custom_object1 = Object.create(keyslength) | |
let custom_object2 = Object.create(valueslength) |
This file contains 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 array = [1, 2, 3, 4, 5] | |
Array.prototype.mult(n) { | |
return this.map((i) => {i * n}) | |
} | |
array.multBy(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment