How to write quotation marks in JavaScript

前端 未结 5 1065
小蘑菇
小蘑菇 2020-12-15 10:25

Hi I want to do the following, but don\'t know how to write the quotation marks

allSearchResults[0]=\"
  • CXS101289/
  • 5条回答
    •  生来不讨喜
      2020-12-15 10:37

      Another, newer and very nice method: Use "multiline strings"!

      Writing it like this, with a backtick at the beginning and end of the string, you can use anything you like inside, and even make use of variable substitution:

      let b = "myvar value";
      let x = `
          
    • ${b}
    • `;

      That case is hard to do otherwise, mixing quotation marks within the string.

    提交回复
    热议问题