简体   繁体   English

运行此程序后出现错误,Uncaught TypeError:无法读取未定义的属性“ push”

[英]I am getting error after run this program, Uncaught TypeError: Cannot read property 'push' of undefined

var nums = [45, 35, 25, 15, 1, 25, 35,];
var dup;
    for(var i = 0; i<nums.length; i++){
    for(var j = nums[i+1]; j<nums.length; j++){
    if(nums[i] == nums[j]) {
    dup.push(nums[i]);
    alert(dup);
    }
    }
}

Please help me in this program, when I am running this program I am getting this error. 请在该程序中帮助我,当我运行该程序时,出现此错误。 I am trying to push duplicate value in dup variable. 我试图在dup变量中推送重复值。 Uncaught TypeError: Cannot read property 'push' of undefined 未捕获的TypeError:无法读取未定义的属性“推”

var nums = [45, 35, 25, 15, 1, 25, 35,];
var dup = []; // Initialize this array

for(var i = 0; i<nums.length; i++) {
  for(var j = i+1; j<nums.length; j++) { // Change this line
    if(nums[i] == nums[j]) {
      dup.push(nums[i]);
      alert(dup);
    }
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我为什么会收到错误:Uncaught TypeError:无法读取未定义的属性“ left” - Why am I getting the error: Uncaught TypeError: Cannot read property 'left' of undefined 我收到错误,因为 Uncaught TypeError: Cannot read property &#39;use&#39; of undefined - I am getting error as Uncaught TypeError: Cannot read property 'use' of undefined 为什么我收到此错误:未捕获的TypeError:无法读取undefined的属性&#39;john&#39; - Why am I getting this error: Uncaught TypeError: cannot read property 'john' of undefined 为什么我收到此错误:“未捕获的TypeError:无法读取未定义的属性'标题'”? - Why am i getting this error: “Uncaught TypeError: Cannot read property 'Title' of undefined”? 偶尔收到“未捕获的TypeError:无法读取未定义的属性&#39;push&#39;” - Getting “Uncaught TypeError: Cannot read property 'push' of undefined” sporadically 捕获TypeError:无法读取未定义的属性“ push” - Getting Uncaught TypeError: Cannot read property 'push' of undefined 我收到一个错误:无法读取未定义的属性“推送” - I am getting an error: Cannot read property 'push' of undefined 类型错误:无法读取未定义的属性“then”。 当我尝试运行 updatefirst 函数时出现此错误 - TypeError: Cannot read property 'then' of undefined. Getting this error when I am trying to run updatefirst function 未捕获的类型错误:无法在 app.js:22 处读取未定义的属性“RecaptchaVerifier”,这是我在浏览器中遇到的错误,请解决 - Uncaught TypeError: Cannot read property 'RecaptchaVerifier' of undefined at app.js:22,this is the error i am getting.in browser,please resolve it 我收到错误“未捕获的 TypeError:未定义不可迭代(无法读取属性 Symbol(Symbol.iterator))”。 无法找到解决方案 - I am getting an error "Uncaught TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))". Unable to find solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM