x = {}
x.valueOf = () => 22
Number(x) // 22
y = []
y.toString = () => '22'
Number(y) // 22
z = {}
z.valueOf() // {} (not a primitive)
z.toString() // "[object Object]" (a string primitive which cannot be coerced to a number)
Number(z) // NaN
Created
February 6, 2018 09:10
-
-
Save amysimmons/76678600c884aa210b7e697e29ae7398 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment