Data type part 4


JavaScript Tutorial
Basic Concepts
Data Types
32
4/5
               

Strings



As strings must be written within quotes, quotes inside the string must be handled. The backslash (\) escape character turns special characters into string characters.
var sayHello = 'Hello world! \'I am a JavaScript programmer.\' ';
document.write(sayHello);
Try It Yourself

Result:
The escape character (\) can also be used to insert other special characters into a string.
These special characters can be added to a text string using the backslash sign.
If you begin a string with a single quote, then you should also end it with a single quote. The same rule applies to double quotes. Otherwise, JavaScript will become confused.
Please enter the corresponding characters to enable the display of the whole string:
var s = "I think
 
 
"JavaScript is
 easy
 
 
" ";
document.write(s)

Comments

Popular posts from this blog

Introducing object part 3

Comparison Operators part 2

Module 2