conststringFive='5';constnumberFive=5;// loose equality, with type conversionconsole.log(stringFive==numberFive);// trueconsole.log(stringFive!=numberFive);// false// strict equality, no type conversionconsole.log(stringFive===numberFive);// falseconsole.log(stringFive!==numberFive);// false// object equality by referenceconstellie1={name:'ellie'};constellie2={name:'ellie'};constellie3=ellie1;console.log(ellie1==ellie2);// falseconsole.log(ellie1===ellie2);// falseconsole.log(ellie1===ellie3);// true// equality - puzzlerconsole.log(0==false);// trueconsole.log(0===false);// falseconsole.log(''==false);// trueconsole.log(''===false);// falseconsole.log(null==undefined);// trueconsole.log(null===undefined);// false
Conditional operators: if
if, else if, else
constname='coder';if(name==='ellie'){console.log('Welcome, Ellie');}elseif(name==='code'){console.log('You are amazing coder');}else{console.log('unknown');}
// while loop, while the condition is truthy,// body code is executed.leti=3;while(i>0){console.log(`while: ${i}`);i--;}// while: 3// while: 2// while: 1// do while loop, body code is executed first,// then check the conditiondo{console.log(`do while: ${i}`);i--;}while(i>0);// do while 3// do while 2// do while 1// do while 0// for loop, for(begin; condition; step)for(i=3;i>0;i--){console.log(`for: ${i}`);}// for: 3// for: 2// for: 1for(leti=3;i>0;i=i-2){// inline variable declarationconsole.log(`inline variable for: ${i}`);}// inline variable for: 3// inline variable for: 1// nested loopsfor(leti=0;i<10;i++){for(letj=0;j<10;j++){console.log(`i: ${i}, j:${j}`);}}// break, continue// Q1. iterate from 0 to 10 and print only even numbers (use continue)for(leti=0;i<=10;i++){if(i%2!==0){continue;}console.log(`q1. ${i}`);}// Q2. iterate from 0 to 10 and print numbers until reaching 8 (use break)for(leti=0;i<=10;i++){if(i>8){break;}console.log(`q2. ${i}`);}
Promise
Promise is a Javascript object for asynchronous operation
State : pending -> fulfilled or rejected
Promise 의 상태가 수행중(pending)인지, 수행완료(fulfilled...
callback
자바스크립트는 동기적임
호이스팅(hoisting)된 이후 순서대로 실행됨
호이스팅(hoisting) : var, funciton 선언이 제일 위로 올라가는 현상
console.log('1');
console.log('2');
console.log('3');...
HTTP
Client, Server 가 Request, Response 하는 프로토콜
ajax : asynchronous javascript and XML
XHR : XMLHttpRequest ajax 요청을 생성하는 javascript API
XML 은 HTML 와 같은 ...