1. Literals & Properties - One of the JavaScript's data types. - a collection of related data and/or functionality. - Nearly all objects in JavaScript are instances of Object. - object = {key: value}; 'use strict' const obj1 = {}; // 'object literal' syntax const obj2 = new Object(); // 'object constructor' syntax function print(person) { console.log(person.name); console.log(person.age); } cons..
1. Object-oriented programming (객체지향 언어) - class : template, declare once, no data in - object : instance of a class, created many times, data in - JavaScript classes (introduced in ES6) : syntactical sugar over prototype-based inheritance 2. Class declarations class Person { // constructor constructor(name, age) { // fields this.name = name; this.age = age; } speak() { console.log(`${this.name}..
1. Function - fundamental building block in the program. - sub-program can be used multiple times. - performs a task or calculates a value. 2. Function declaration - function name(param1, param2) {body... return;} - one function === one thing - naming : doSomething, command, verb - e.g. createCardAndPoint -> createCard, createPoint - function is object in JS function printHello() { console.log('..
0. 프로그래밍에서 가장 중요한 것? 입력, 연산, 출력, CPU에 최적화된 연산, 메모리 사용의 최소화 1. Variable : let 변경할 수 있는 값. JS에서 변수의 선언은 오직 let으로만 할 수 있다. 이전까지는 var를 사용했으나, ES6부터 let을 사용하게 되었다. 대부분의 프로그래밍 언어에서는 변수를 선언한 후 값을 할당할 수 있는데, var는 선언하지 않고 값을 할당하거나 출력할 수 있었다. 이를 var hoisting이라 한다. 면접에서 물어볼 수 있으니 기억해두자. 또한, var는 block scope를 무시해서 어디서든 출력할 수 있다. 이러한 단점과 위험부담 때문데 let이 나오게 되었다. var hoisting : move declaration from bottom to t..