//遍历对象let person={fname:"Bill",lname:"Gates",age:56};for(x in person){// x 为属性名
txt=txt + person[x];}//遍历数组for(x in nums){// x 为数组索引
document.write(nums[x]+"<br />");}
3.for-of 的语法(ES6支持)
let totalNumber=[]const number=[10,30,40]//1.for(let item of number){//item为数组元素的值
totalNumber.push(item)}