Page 142 - DCAP408_WEB_PROGRAMMING
P. 142

Web Programming




                    Notes                        “This  is  a  string”
                                                 ‘This  is  another  string’
                                                 “This  is  also  ‘a  string’  “
                                                 This  is  “a  string”’
                                   An empty set of quotes is called the null string. If a number is enclosed in quotes, it is considered
                                   a string; e.g., “5” is a string, whereas 5 is a number.
                                   Strings are called constants or literals. The string value “hello” is called a string constant or
                                   literal.




                                     Notes   To change a string requires replacing it with another string.
                                   Strings can contain escape sequences (a single character preceded with a backslash), as shown in
                                   Table 5.2. Escape sequences are a mechanism for quoting a single character.

                                                               Table  5.2: Escape  Sequences
                                          Escape  Sequence                       What It  Represents

                                          \’                                     Single quotation mark
                                          \”                                     Double quotation mark
                                          \t                                     Tab

                                          \n                                     Newline
                                          \r                                     Return
                                          \f                                     Form  feed
                                          \b                                     Backspace
                                          \e                                     Escape

                                          \\                                     Backslash

                                   Special Escape Sequences
                                          \XXX                 The character with the Latin-1 encoding specified by up to
                                                               three octal digits XXX between 0 and 377. \251 is the octal
                                                               sequence for the copyright symbol.
                                          \xXX                 The character with the Latin-1 encoding specified by the
                                                               two hexadecimal digits XX between 00 and FF. \xA9 is the
                                                               hexadecimal sequence for the copyright symbol.
                                          \uXXXX               The Unicode character specified by the four hexadecimal
                                                               digits XXXX. \u00A9 is the Unicode sequence for the
                                                               copyright symbol.


                                          Example: Illustrating strings in java script.

                                              <html>
                                              <head>
                                              <body>


          136                               LOVELY PROFESSIONAL UNIVERSITY
   137   138   139   140   141   142   143   144   145   146   147