①The for in statement loops through the JavaScript object. Each time it loops, it will obtain a property or method of the object.
Syntax:
for(valueName in ObjectName){
// Code block
}
Among them, valueName is the variable name, which saves the name of the attribute or method. The value of valueName will change every time it loops.
Example:
var item_info = {'ITEM000000':{
barcode: 'ITEM000000',
name: 'Coca-Cola',
unit: 'bottle',
price: 3.00
},'ITEM000004':{
barcode: 'Item000004',
name: 'battery',
unit: ',
price: 2.00}};
For (var j in item_info) ----- & gt; Change. 】
{shopping_list='name:'+item_info[j].name}
②Create an empty object instead of nested loop for optimization
var item_info = {};
for(var i=0;i
item_info[inputs[i].barcode].count+= 1;----> ;[It’s best to use targeted data to represent keys]
} else{
use through using ’ through ’ through ’ through’ use ’ through ’ through ’ through ’ through ’s ’ through ’ through ‐ to ‐ ‐‐‐‐‐‐ and ‐ } to ③ Naming
is generally a noun and a function is a verb