Home  >  Q&A  >  body text

关于JS,+=连接字符串,为什么一定要前面加str +=才能连接啊?

 var str = "窗口左边距离:"+e.clientX+",窗口顶边距离:"+e.clientY;

                str += "\n网页左边距离:"+e.pageX+",网页顶边距离:"+e.pageY;

                str += "\n屏幕左边距离:"+e.screenX+",屏幕顶边距离:"+e.screenY;

                str += "\n事件类型:"+e.type;

谢谢!

php实习生php实习生2816 days ago1103

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:31:48

    Regarding JS, += connection string, why must we add str += in front to connect? -PHP Chinese website Q&A-About JS, += connection string, why must we add str += in front to connect? -PHP Chinese website Q&A

    Let’s take a look and learn.

    reply
    0
  • 阿神

    阿神2017-02-25 17:22:05

    str +=字符串  等于  str =str+字符串  这两个语句是相等的

    上面的意思是把字符串加在str后面,组成一个整体的字符串

    reply
    0
  • Cancelreply