How to prevent values from being converted to strings in javascript?

前端 未结 5 1725
灰色年华
灰色年华 2021-01-20 16:58
    var str;
    var displayedNum;
    for (i in imgURLArray){
        str = \"
  • \" + \"\"+ (1+i) + \"\" + \"
  • \
    5条回答
    •  时光说笑
      2021-01-20 17:07

      Try wrapping numbers in Number()

      Like:

      var i = 1;
      
      var str = "foobar" + Number(1+i) + "other stuff";
      

    提交回复
    热议问题