Skip to content

Incorrect explanation of object to primitive #1569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dheeraj-br opened this issue Nov 3, 2019 · 1 comment
Closed

Incorrect explanation of object to primitive #1569

dheeraj-br opened this issue Nov 3, 2019 · 1 comment

Comments

@dheeraj-br
Copy link

Issue in the section 'Object to primitive conversion' under the 'toString/valueOf' here as well as in the summary section

It is implied that while converting Object to string the toString is called first if its not present then vallueOf is called, this is not correct, because if toString is not present javascript calls the Object.prototype's toString method which outputs "[Object Object]"

Here is Demo on JsBin https://jsbin.com/vikisihosa/edit?js,output

@iliakan iliakan closed this as completed in 611fefd Nov 3, 2019
@iliakan
Copy link
Member

iliakan commented Nov 3, 2019

Sorry for confusion, I added more explanations about that, to make things clearer.

P.S. We can't mention prototype in this section of the tutorial, so I'm talking about "default" toString.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants