I used to write multiline strings in JavaScript like this:


var str = 'This is ' +
'a very long ' +
'sentence.'

Sometimes, i wrote it this way:

var str = ['This is ',
'a very long ',
'sentence.'].join('');

Using array to contact strings is an effective way. I also see an implement of StringBuilder in JavaScript using this technology.

Today, i was surprised to find the third way:

var str = 'This is \
a very long \
sentence.';

just cool!

相关文章:

  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
  • 2021-10-14
  • 2021-09-20
  • 2022-01-12
猜你喜欢
  • 2021-06-01
  • 2022-12-23
  • 2021-05-21
  • 2021-12-25
  • 2022-12-23
  • 2021-04-15
  • 2021-12-19
相关资源
相似解决方案