• 赚钱入口【需求资源】限时招募流量主、渠道主,站长合作;【合作模式】CPS长期分成,一次推广永久有收益。主动打款,不扣量;

Javascript String([‘a’, ‘b’, ‘c’]) 和 `${[‘a’, ‘b’, ‘c’]}` 区别

JavaScript cps12345 1个月前 (09-19) 30次浏览 0个评论

String(someExpression) is identical to:

`${someExpression}`

But template literals are generally used only when you need to do a bit more than cast something to a string – like to interpolate an expression into the middle of something else in a string, eg:

`foo${['a', 'b', 'c'}]`

in order to result in

fooa,b,c

Otherwise, if you just have a single expression to turn into a string, using String may be a bit clearer that you’re only casting a single expression to a string, rather than doing anything else, and so may look a bit less confusing to some than using a template literal.

喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址