String string data type
All single and double quotation marks, the anti-wrap are quoted string.
Other types of values converted to a string
- [val].toString()
- String concatenation
var age =18;
var ageAsString = age.toString() // "11"
let a = 10 + null + true + [] + undefined + 'Hello' + null + [] + 10 + false;
console.log(a) // 11undefinedHellonull10false
console.log(let a = 10 + null + true + [] + undefined + 'Hello' + null + [] + 10 + false;
console.log(10 + null + true + [] + undefined + 'Hello' + null + [] + 10 + false)
let str = 'Hello World'
Case Analysis:
- The first step,
10 + null => 10
null value is converted into 0, 10 + 0 = 10. - The second step,
10 + true => 11
to true value is converted to 1, 10 + 11 = - The third step,
11 + [] => "11"
[] is converted to an empty string, numeric and string + number changes encountered connector 11 + "" = "11" - The fourth step,
"11" + undefined
=> "11undefined" after the + strings using, as a connector, the back of the same - All final result is 11undefinedHellonull10false