전체 글 썸네일형 리스트형 JavaScript Promise javascript Promise Promise is a Javascript object for asynchronous operation 1.state 2.producer vs consumer Producer //불필요한 네트워크 받을 수있다 (executor 함수가 자동적으로 실행이 되기때문이다) // the executor runs automatically const promise = new Promise((resolve, reject) => { //heavy work ); Consumer(then, catch, finally) promise.then(value => { }); 더보기 JavaScript callback function JavaScript is synchronous Execute the code block by orger after hoisting hoisting: var, function declaration Synchronous callback 동기적 function printTestA(print) { print(); } Asynchronous callback 비동기적 function printTestB(print, timeout) { setTimeout(print, timeout); } 콜백 지옥에 빠질수 있으니 조심할것 콜백지옥 단점1.가독성 떨어진다 단점.2 디버깅,문제분석이 어려움 더보기 JavaScript Json(1일차 공부정리) JSON javascript object Notation 1. object to JSON stringify(obj) ex) json = JSON.stringify(monster) 2. JSON to object parse(json) const obj = JSON.parse(json) 유의1.)object를 json 변경하면 string변환해서 보내기때문에 json에서 object로 변경할때 string으로 받는다 유의2.)object에서 메서드를 만들고 json으로 변경후 다시 json에서 object 변경할때 데이터만 갔다왔기 때문에 함수는 함수는 Serialize될때 포함이 안되서 함수호출이 안됨 더보기 이전 1 ··· 14 15 16 17 다음