Skip to content

Instantly share code, notes, and snippets.

@kumavis
Last active December 5, 2019 14:08
Show Gist options
  • Save kumavis/cfec971e3224252f038a8ae575925b3e to your computer and use it in GitHub Desktop.
Save kumavis/cfec971e3224252f038a8ae575925b3e to your computer and use it in GitHub Desktop.
more javascript hijinks
> x = 'hello'
'hello'
> x.toString = () => 'ayy'
[Function]
> x.valueOf = () => 'yoo'
[Function]
> x
'hello'
> x+''
'hello'
> String(x)
'hello'
> y = Object(x)
[String: 'hello']
> y.valueOf = () => 'yoo'
[Function]
> y.toString = () => 'ayy'
[Function]
> y
{ [String: 'hello'] valueOf: [Function], toString: [Function] }
> y+''
'yoo'
> String(y)
'ayy'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment