vue学習のES 6_02(対象深度コピー、対象合併、mapとreduce)




	
		
		
		Study ES6
	
	
		
Hello ES6
// let p1={name:'zs',age:26}; // let someone={...p1}; writeLine(JSON.stringify(p1)); writeLine(JSON.stringify(p1)); // let name1={name:'Alice'}; let age1={age:24}; let p2={...name1,...age1}; writeLine(JSON.stringify(p2)); //map(): , let arr=[4,20,12,13] //reduce(): , arr=arr.map(item=>item+1); writeLine(arr); /* reduce */ /* , , arr.reduce(callback,[initialValue]) callback : 1、previousValue ( , (initialValue)) 2、currentValue ( ) 3、index ( ) 4、array ( reduce ) */ let result=arr.reduce((a,b,index,d)=>{ writeLine(' '+a); writeLine(' '+b); writeLine(' '+index); writeLine(' '+d); return a+b; }); writeLine(result); // function writeLine(s) { document.write(s + "<br>") }