JS 문법 정리 (5)
·
Programming/JavaScript
0. Literals and properties one of the JS 's data types a collection of related data and/or functionality. Nearly all objects in JS are instances of object object = { key : value }; const obj1 = {}; // 'object literal' syntax const obj2 = new Object(); // 'object constructor' syntax function print(person){ console.log(person.name); console.log(person.age); } const cucu = { name : 'cucu', age : '1..
JS 문법 정리 (3)
·
Programming/JavaScript
0. Function function name (param1, param2) { body . . . return;} one function === one thing naming : doSomething, command, verb function is object in JS!!! → ~prototype~ + TypeScript Playground function log(message : string) : number { console.log(message); return; } 1. Parameters function changeName(obj){ obj.name = 'cucu'; } const bob = { name: "bob"}; changeName(bob); console.log(bob); 2. Def..
JS 문법 정리 (2)
·
Programming/JavaScript
0. String concatenation console.log(`string literals : '''' 1+2=${1+2}`); 1. Increment and decrement operators let counter = 2; const preIncrement = ++counter; counter = counter + 1; preIncrement = counter; const postIncrement = counter++; postIncrement = counter; counter = counter + 1; 2. Logical operators || or : finds the first truthy value value1 || value2 || check() // true 는 뒤로!! && and : ..
JS 문법 정리
·
Programming/JavaScript
0. async vs defer head + defer 1. 'use strict'; 문법 실수 확인 가능 2. Variable, rw(read/write) let{} ES6 밖에서 정의하면 업데이트X global name : 밖에서 정의 가능 var hoisting : move declaration from bottom to top, has no block scope * var 은 쓰지 마세요 → 설정 전에 출력 가능하기 때문 3. Constant, r(read only) use const whenever possible only use let if variable needs to change favor immutable data type always for a few reason - security ..