Update 1-js/02-first-steps/08-operators/article.md
Co-authored-by: Vse Mozhe Buty <vsemozhetbyt@gmail.com>
This commit is contained in:
parent
5c0ea294ce
commit
634e066841
1 changed files with 1 additions and 1 deletions
|
@ -109,7 +109,7 @@ Here, operators work one after another. The first `+` sums two numbers, so it re
|
||||||
```js run
|
```js run
|
||||||
alert('1' + 2 + 2); // "122" and not "14"
|
alert('1' + 2 + 2); // "122" and not "14"
|
||||||
```
|
```
|
||||||
Here, the first operand is a string, the compiller treats the other two operands as string too. The `2` gets concatinated to `'1'`, so it's like `'1' + 2 = "12"` and `"12" + 2 = "122"`
|
Here, the first operand is a string, the compiler treats the other two operands as strings too. The `2` gets concatenated to `'1'`, so it's like `'1' + 2 = '12'` and `'12' + 2 = '122'`.
|
||||||
|
|
||||||
The binary `+` is the only operator that supports strings in such a way. Other arithmetic operators work only with numbers and always convert their operands to numbers.
|
The binary `+` is the only operator that supports strings in such a way. Other arithmetic operators work only with numbers and always convert their operands to numbers.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue