Last active
November 12, 2021 05:12
-
-
Save juan-calle/33491af059105ae1ae23071bb62d5066 to your computer and use it in GitHub Desktop.
JSnippets
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 cloneObject(object) { | |
return Object.entries(object).reduce((result, [key, value]) => { | |
result[key] = value | |
return result | |
}, {}) | |
} | |
let myObject = { a: 1, b: 2 } | |
console.log(cloneObject(myObject)) | |
// => { a: 1, b: 2 } |
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
/* | |
* snippet to quicky check the type of anything in JS | |
*/ | |
const typeOf = somthing => | |
Object.prototype.toString.call(somthing).slice(8, -1).toLowerCase() | |
console.log(typeOf(fetch('http://localhost'))) // > Promise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment