21/10/13

  1. Ternary Operator

    if랑 else if 이렇게 두개의 조건으로만 이루어진경우

    ex) score > 5 ? 'good' : 'no';

  2. Nullish coalescing operator

    Bad Code

    function printMessage(text) {
    
    	let message = text;
    	if ( text == null || text == undefined) {
    		message = 'Nothing to display';
    	}
    	console.log(message);
    }
    

    Good Code

    function printMessage(text) {
    	const message = text ?? 'Nothing to display';
    	console.log(message);
    

    leftExpr ?? rightExpr

    왼쪽이 null, undefined이여야만 오른쪽 코드 실행

    leftExpr || rightExpr

    왼쪽이 falsy(거짓)인경우만 오른쪽 코드 실행

    flasy = false, undefined, null, 0 , -0, Nan , "", '' ,``

    함수로도 가능

  3. Object Destructuring

    Untitled

  4. Spread Syntax - Object

    Untitled

    Untitled

    Untitled

  5. optional-chaining

    Untitled

  6. template-literals

    Untitled

  7. loops

    Untitled