#x2B+;我和我+;1在javascript中

#x2B+;我和我+;1在javascript中,javascript,indexof,Javascript,Indexof,这怎么能给我不同的结果 唯一的区别是[++i]和[i+1] function adjacentElementsProduct(inputArray) { total = inputArray[0] * inputArray[1]; for (i = 1; i < inputArray.length-1; i++) { mul = inputArray[i] * inputArray[++i]; if (total < mul) total = m

这怎么能给我不同的结果

唯一的区别是[++i]和[i+1]

function adjacentElementsProduct(inputArray) {
  total = inputArray[0] * inputArray[1];

  for (i = 1; i < inputArray.length-1; i++) {
    mul = inputArray[i] * inputArray[++i];
    if (total < mul)
      total = mul;
      }
  return total;
}

    function adjacentElementsProduct(inputArray) {
  total = inputArray[0] * inputArray[1];

  for (i = 1; i < inputArray.length-1; i++) {
    mul = inputArray[i] * inputArray[i+1];
    if (total < mul)
      total = mul;
      }
  return total;
}
函数邻接元素产品(输入阵列){
总计=输入阵列[0]*输入阵列[1];
对于(i=1;i
谢谢你的帮助


这个问题被标记为重复,但其他问题是关于i++的,我的是关于++i的。

+i
i
增加一个,并将新值保存到
i

i+1
i
中的当前值增加1,但不将新值保存到
i

还要检查这个问题

例如,如果使用以下命令调用函数:AdjaceEntElementsProduct([3,6,-2,-5,7,3])<代码>++i
有一个
i+1
没有的副作用。这应该是一个足够的暗示。非常感谢