Object to primitive conversion by MykolaSopiha · Pull Request #154 · javascript-tutorial/uk.javascript.info
Repository navigation
Object to primitive conversion - #154
Merged
tarasyyyk merged 7 commits into javascript-tutorial:master from MykolaSopiha:object-to-primitive Jul 27, 2021
Merged
Object to primitive conversion #154 tarasyyyk merged 7 commits into javascript-tutorial:master from MykolaSopiha:object-to-primitive
Conversation
MykolaSopiha commented Jul 25, 2021
Copy link Copy Markdown
Collaborator
No description provided.
MykolaSopiha added 2 commits July 24, 2021 20:19
wip: object to primitive conversion
195233e
object to primirive
1a10ae9
javascript-translate-bot
added
the
review needed
label
Jul 25, 2021
MykolaSopiha
changed the title
Object to primitive
Object to primitive conversion
Jul 25, 2021
fix: object to primirive
7d81121
tarasyyyk
reviewed
Jul 27, 2021
View reviewed changes
Update 1-js/04-object-basics/09-object-toprimitive/article.md
c2331bc
tarasyyyk
reviewed
Jul 27, 2021
View reviewed changes
Update 1-js/04-object-basics/09-object-toprimitive/article.md
79ea62f
tarasyyyk
reviewed
Jul 27, 2021
View reviewed changes
Update 1-js/04-object-basics/09-object-toprimitive/article.md
b571977
tarasyyyk
reviewed
Jul 27, 2021
View reviewed changes
small fixes
e3c79a0
tarasyyyk
approved these changes
Jul 27, 2021
View reviewed changes
tarasyyyk left a comment
Copy link Copy Markdown
Collaborator
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Дякую за переклад!
Додав пару нових рядків, щоб номери рядків збігалися з оригінальним текстом.
f2956c5
into
javascript-tutorial : master
Jul 27, 2021
javascript-translate-bot
mentioned this pull request
Jul 27, 2021
Ukrainian Translation Progress
#1
Open
javascript-translate-bot commented Jul 27, 2021
Copy link Copy Markdown
Contributor
|
Thank you 💖 I updated the Progress Issue #1 🎉 🎉 🎉 |
UkrainianCitizen commented Jul 30, 2021 · edited Loading
Copy link Copy Markdown
Contributor
|
Еммммммм................. я почав робити рев'ю, а ти замерджив |
UkrainianCitizen commented Jul 30, 2021 · edited Loading
Copy link Copy Markdown
Contributor
|
Там були граматичні, семантичні та помилки перекладу |
View reviewed changes
Comment thread 1-js/04-object-basics/09-object-toprimitive/article.md
| Що відбувається, коли об'єкти додаються `obj1 + obj2`, віднімаються `obj1 - obj2` або друкуються за допомогою `alert(obj)`? | ||
|
|
||
| JavaScript doesn't exactly allow to customize how operators work on objects. Unlike some other programming languages, such as Ruby or C++, we can't implement a special object method to handle an addition (or other operators ). | ||
| JavaScript не дозволяє налаштувати, як працюють оператори з об'єктами. На відміну від деяких інших мов програмування, таких як Ruby або C++, ми не можемо реалізувати спеціальний об'єктний метод для обробки додавання (або інших операторів ). |
| JavaScript не дозволяє налаштувати, як працюють оператори з об'єктами. На відміну від деяких інших мов програмування, таких як Ruby або C++, ми не можемо реалізувати спеціальний об'єктний метод для обробки додавання (або інших операторів ). | ||
|
|
||
| In case of such operations, objects are auto-converted to primitives, and then the operation is carried out over these primitives and results in a primitive value . | ||
| У разі таких операцій об'єкти автоматично перетворюються на примітиви, а потім операція здійснюється над цими примітивами та повертає результат у вигляді примітивного значення . |
| Це важливе обмеження, оскільки результат `obj1 + obj2` не може бути іншим об'єктом ! | ||
|
|
||
| E.g. we can't make objects representing vectors or matrices (or archievements or whatever), add them and expect a "summed" object as the result. Such architectural feats are automatically "off the board" . | ||
| Наприклад, ми не можемо зробити об'єкти, що представляють вектори або матриці (або досягнення або що завгодно) та додати їх і очікувати, що "підсумковий" результат буде об'єктом. Автоматично такі архітектурні особливості недоступні . |
| У цьому розділі ми розглянемо те, як об'єкти перетворюється на примітиви і як налаштувати це . | ||
|
|
||
| We have two purposes : | ||
| У нас є два цілі : |
|
|
||
| 1. It will allow us to understand what's going on in case of coding mistakes, when such an operation happened accidentally . | ||
| 2. There are exceptions, where such operations are possible and look good. E.g. subtracting or comparing dates (`Date` objects ). We'll come across them later . | ||
| 1. Це дозволить нам зрозуміти, що відбувається у випадку помилок коду, коли така операція відбулася випадково . |
| Наприклад, ми не можемо зробити об'єкти, що представляють вектори або матриці (або досягнення або що завгодно) та додати їх і очікувати, що "підсумковий" результат буде об'єктом. Автоматично такі архітектурні особливості недоступні . | ||
|
|
||
| So, because we can't do much here, there's no maths with objects in real projects. When it happens, it's usually because of a coding mistake . | ||
| Отже, оскільки ми не можемо автоматично за допомогою мови програмування виконувати подібні операції над об'єктами, то в реальних проєктах немає "математики з об'єктами". Коли стаються подібні операції (наприклад, `obj1 + obj2`), причиною цьому зазвичай є помилка програмування . |
| ## Правила перетворення | ||
|
|
||
| In the chapter <info:type-conversions> we've seen the rules for numeric, string and boolean conversions of primitives. But we left a gap for objects. Now, as we know about methods and symbols it becomes possible to fill it . | ||
| У розділі <info:type-conversions> ми бачили правила для перетворення чисел, рядків та булевих примітивів. Але ми залишили пробіл для об'єктів. Тепер, оскільки ми знаємо про методи та символи, можемо заповнити його . |
| 1. All objects are `true` in a boolean context. There are only numeric and string conversions . | ||
| 2. The numeric conversion happens when we subtract objects or apply mathematical functions. For instance , `Date` objects (to be covered in the chapter <info:date>) can be subtracted, and the result of `date1 - date2` is the time difference between two dates . | ||
| 3. As for the string conversion -- it usually happens when we output an object like `alert(obj)` and in similar contexts . | ||
| 1. Всі об'єкти -- це `true` в булевому контексті. Є лише числові та рядкові конверсії . |
| 1. All objects are `true` in a boolean context. There are only numeric and string conversions . | ||
| 2. The numeric conversion happens when we subtract objects or apply mathematical functions. For instance , `Date` objects (to be covered in the chapter <info:date>) can be subtracted, and the result of `date1 - date2` is the time difference between two dates . | ||
| 3. As for the string conversion -- it usually happens when we output an object like `alert(obj)` and in similar contexts . | ||
| 1. Всі об'єкти -- це `true` в булевому контексті. Є лише числові та рядкові конверсії . |
| # Перетворення об'єктів в примітиви | ||
|
|
||
| What happens when objects are added `obj1 + obj2`, subtracted `obj1 - obj2` or printed using `alert(obj)`? | ||
| Що відбувається, коли об'єкти додаються `obj1 + obj2`, віднімаються `obj1 - obj2` або друкуються за допомогою `alert(obj)`? |
UkrainianCitizen commented Jul 30, 2021
Copy link Copy Markdown
Contributor
|
І я не закінчив рев'ю |
tarasyyyk commented Aug 3, 2021
Copy link Copy Markdown
Collaborator
Незнав, що Ви робите рев'ю. |