만약 객체에 없는 값을 찍으면 undefined가 뜬다 const ob = { name: 'jae', age: 25, uni: 'harvard', major: 'sw' } console.log(ob.country); ?연산자 지금은 콘솔환경이라 undefined 나 나타나지만 나중에 서버환경에서는 errorr가 발생할수있다 만약 어떤 객체에 존재하지 않는 속성에 접근하려고 하면 error가 나타날수 있다 그래서 있는지 없는지 확실치 않을때 ? 를 붙이면 error 대신 undefined를 return 해준다 console.log(ob?.country?.hi.hello.how.are.you); ?? 연산자 console.log(ob.country ?? "seoul"); ob.country 가 null 이면..
🤷♂️ fetch란? fetch 는 client가 서버에 요청을 보낼 때 사용하는 함수이다. 예를 들어, fetch('javascript') 라는 표현은 "웹브라우저야, javascript 라는 파일을 서버에 응답해줘" 라는 뜻이다. 동기(synchronous) : A가 끝나야 그 다음 B를 실행하는 처리방식 비동기(Asynchronous) : A가 끝나지 않아도 B를 실행하는 처리방식 기본적으로 fetch() 함수는 비동기 처리에 해당한다. fetch를 동기적 처리로 만들기 위해 .then()을 사용한다. 🧑💻 예제 코드 function callBackMe() { console.log("response end") } fetch('html').then(callBackMe); console.log(1)..