JavaScript Tutorial | Beginner | Strings with Arithmetic Operators | Chap-3 | Part-6

preview_player
Показать описание
Part six of chapter three continues with the explanation on using concatenation or arithmetical addition operator with strings and numbers. In JavaScript, even if a number is enclosed as the type of string primitive data type and added with numeric literals, then JavaScript compiler will perform standard addition on the numbers while the newly added value will be turned into string and will be joined with the already existing string. Due to the immutable nature of primitive data types in JavaScript, number to string conversion destroys the previous data type and replaces it with the new one for storage in a variable. How the number to string conversion will occur depends on the order of the placement of numbers/digits and strings. JavaScript compiler starts to read in the a left-to-right format which means if a string numeric literal comes first, then that number will be added as its own types literal before converting if such an option exists for the compiler. When other operators are used with string literals in JavaScript, the strings are rather converted to number data types, if the strings hold numbers as their values, and added to the following numerals. The next video tutorial will deal with the string to number conversions. STAY TUNED!

SUBSCRIBE---SHARE---LIKE --------Follow me on Twitter : @ahmd_nafis
Рекомендации по теме