Es6新增数组遍历

for
for in
for of 只能遍历数组

	var arr = [43,6,5,78,8];        
	for(var ele of arr){
                 
	console.log(ele)        
	} 

迭代器

	var arr = [43,6,5,78,8];        
	var keys = arr.keys();        
	for(var index of keys){
                 
	console.log(index);        
	}

遍历元素

	var arr = [43,6,5,78,8];        
	var values = arr.values();        
	for(var ele of values){
                 
	console.log(ele);        
	}
	var arr = [43,6,5,78,8];                
	var entries = arr.entries();        
	var ele1 = entries.next().value;        
	var ele2 = entries.next().value;        
	console.log(ele1)        
	console.log(ele2)

你可能感兴趣的:(javascrip,实践操作)