手書きES 6プロミス



    
    
    
    	
    	promise      
    
    
    		
    
    
     
    	//   promise  (   )
    	let promise = new Promise((resolve,reject) => {
    		//    promise   : pending
    		console.log(111)
    		//       ,     ajax  ,     
    		setTimeout(() => {
    			console.log(333)
    			//               promise   (  )
    			//       
    			resolve('      !');//     promise     : fullfilled
    			//       
    			reject(); //     promise     : rejected
    		},2000)
    	})
    	console.log(222);//    111  222
    	
    	promise.then((data) => {//     
    		console.log(data, '   ');// resolve()      
    	},(error) => {//      
    		console.log('   ');// reject()      
    	})