String Operators
COURSES CODE PLAYGROUND DISCUSS TOP LEARNERS String Operators 39 1/1 String Operators The most useful operator for strings is concatenation , represented by the + sign. Concatenation can be used to build strings by joining together multiple strings, or by joining strings with other types: var mystring1 = "I am learning "; var mystring2 = "JavaScript with SoloLearn."; document.write(mystring1 + mystring2); Try It Yourself The above example declares and initializes two string variables, and then concatenates them. Numbers in quotes are treated as strings: "42" is not the number 42, it is a string that includes two characters, 4 and 2. What is the output of the following code: var x = "50"; var y = "100"; document.write(x+y); 50100 5000 Null 150
Comments
Post a Comment