Skip to content
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

Object to primitive #1564

Merged
merged 17 commits into from
Apr 15, 2022
Merged

Object to primitive #1564

merged 17 commits into from
Apr 15, 2022

Conversation

Rnbsov
Copy link
Contributor

@Rnbsov Rnbsov commented Mar 31, 2022

https://javascript.info/object-toprimitive

Ссылка на эту статью в репозитории en.javascript.info

Есть вопрос с переводом строк 90-94 (выделил квадратными скобками и курсивом)

  1. Вызов obj[Symbol.toPrimitive](hint) - метод с символьным ключом Symbol.toPrimitive (системный символ), если такой метод существует,
  2. В случае, если хинт равен "string"
    - пробует obj.toString() и obj.valueOf(), [независимо от того, что существует.]
  3. В случае, если хинт равен "number" или "default"
    - пробует obj.valueOf() и obj.toString(), [независимо от того, что существует.]

Стоит ли записать их так же как и строки 269-273 (выделил квадратными скобками и курсивом)

  1. Сначала вызывается метод obj[Symbol.toPrimitive](hint), если он существует,
  2. В случае, если хинт равен "string"
    - происходит попытка вызвать obj.toString() и obj.valueOf(), [смотря что есть.]
  3. В случае, если хинт равен "number" или "default"
    - происходит попытка вызвать obj.valueOf() и obj.toString(), [смотря что есть.]

И ещё, нужна ли часть на строке 244? (которая выделена жирным)

А вот, к примеру, бинарный плюс в подобной ситуации соединил бы строки, так как он совсем не брезгует строк:

@javascript-translate-bot javascript-translate-bot added the review needed Review needed, please approve or request changes label Mar 31, 2022
@javascript-translate-bot javascript-translate-bot requested a review from a team March 31, 2022 20:38
@iliakan iliakan merged commit 35786d1 into javascript-tutorial:master Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review needed Review needed, please approve or request changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants