From fa4c9bed29e191f193869b8e9064bb27c4fa640a Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Tue, 18 Aug 2015 15:15:50 +0300 Subject: [PATCH] operators --- 1-js/2-first-steps/8-operators/article.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/1-js/2-first-steps/8-operators/article.md b/1-js/2-first-steps/8-operators/article.md index 25197273..44091436 100644 --- a/1-js/2-first-steps/8-operators/article.md +++ b/1-js/2-first-steps/8-operators/article.md @@ -58,6 +58,18 @@ alert( '1' + 2 ); // "12" alert( 2 + '1' ); // "21" ``` +Note that it doesn't matter whether the first operand is a string or the second one. The rule is simple: if any of operands is a string, then convert the other one into a string as well. + +The string concatenation and conversion is the special feature of the binary plus `"+"`. Other arithmetic operators work only with numbers. They always convert their operands into numbers. + +For instance: + +```js +//+ run +alert( 2 - '1' ); // 1 +alert( 6 / '2' ); // 3 +``` + ### Преобразование к числу, унарный плюс +