String Variables

JavaScript string variables should be enclosed in either single or double quotation marks, like this:

greeting = "Hello there"
warning = 'Be careful'

You may include a single quote within a double-quoted string or a double quote within a single-quoted string. But a quote of the same type must be escaped using the backslash character, like this:

greeting = "\"Hello there\" is a greeting"
warning = '\'Be careful\' is a warning'

To read from a string variable, you can assign it to another one, like this:

newstring = oldstring

or you can use it in a function, like this:

status = "All systems are working"

You may also like...