Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JSnippets
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 }
/*
* 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