Skip to content

Instantly share code, notes, and snippets.

@djD-REK
Created September 19, 2019 20:40
Show Gist options
  • Save djD-REK/7cb92242050403b3d42bc1638aa85962 to your computer and use it in GitHub Desktop.
Save djD-REK/7cb92242050403b3d42bc1638aa85962 to your computer and use it in GitHub Desktop.
const primitiveString = `Hello world!` // primitive type string
const wrappedString = new String(`Hello world!`) // wrapper object
console.log(typeof primitiveString) // "string"
console.log(typeof wrappedString) // "object"
console.log(primitiveString == wrappedString) // true
console.log(primitiveString === wrappedString) // false
const almostWrappedString = String(`Hello world!`) // wrapper called without new
console.log(typeof almostWrappedString) // "string"
console.log(primitiveString === almostWrappedString) // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment