JS字符串、运算符、比较、条件按语句、

1、字符串

  可以用单引号 或者双引号  ,在 JavaScript 中,字符串写在单引号或双引号中。因为这样,以下实例 JavaScript 无法解析:

   "We are the so-called "Vikings" from the north." 
      字符串 "We are the so-called " 被截断。

   如何解决以上的问题呢?可以使用反斜杠 (\) 来转义 "Vikings" 字符串中的双引号,如下:

     "We are the so-called \"Vikings\" from the north."

    反斜杠是一个转义字符。 转义字符将特殊字符转换为字符串字符:也可以里面的使用单引号,这样就可以不用转义字符。

猜你喜欢

转载自www.cnblogs.com/liaoxun/p/10046999.html
今日推荐