简体   繁体   English

我无法理解代码

[英]I am not able to understand the code

I am new to javascript.我是 javascript 新手。 After lots of hours I am not able to understand the code.很多小时后,我无法理解代码。 I would be grateful if someone could help me.如果有人可以帮助我,我将不胜感激。 Thanks谢谢

for(var x = 0; x < id_inters['inters'].length; x++) {
    var a,b;
    if(id_inters['inters'][x]['First_ID'] == data.main[0].cust) {
        a = id_inters['inters'][x]['First_ID'];
        b = id_inters['inters'][x]['Second_ID2'];

You can take it with these steps from the for loop:您可以从 for 循环中执行以下步骤:

  1. var x is declared and assigned value of 0. var x 已声明并赋值为 0。
  2. There will be an Object named id_inters which hold an array named inters which also holds objects in it.将有一个名为对象id_inters持有数组名为inters也拥有它的对象。
  3. Now inside the loop you declare two variables var a, b;现在在循环中声明两个变量var a, b; . .
  4. Now that n the condition you are checking the value of the iterated object with id_inters['inters'][x]['First_Id'] where x is the index number if each iteration which is incremented from 0 to length of array.现在,您正在使用id_inters['inters'][x]['First_Id']检查迭代对象的值,其中x是索引号,如果每次迭代从 0 增加到数组长度。
  5. And you are checking each iterated value to the first value of the data['main'][0].cust .并且您正在将每个迭代值检查为data['main'][0].cust的第一个值。 Where data is an object which contains an array named data and you are comparing its first object's cust value.其中 data 是一个包含名为 data 的数组的对象,您正在比较其第一个对象的 cust 值。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM