Skip to content

Instantly share code, notes, and snippets.

@juan-calle
Last active November 12, 2021 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juan-calle/33491af059105ae1ae23071bb62d5066 to your computer and use it in GitHub Desktop.
Save juan-calle/33491af059105ae1ae23071bb62d5066 to your computer and use it in GitHub Desktop.
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