목록Web Front-end (55)
할머니의 콤퓨타 도전기
JSON(JavaScript Object Notation) simplest data interchange format lightweight text-based structure easy to read key-value pairs used for serialization and transmission of data between the network the network connection independent programming language and platform object --> string (serialize) string --> object (deserialize) Object to JSON stringify(obj) let json = JSON.stringify(true); // boole..
Array Declaration const arr1 = new Array(); const arr2 = [1, 2]; Index position const fruits = ['apple', 'banana']; console.log(fruits); console.log(fruits.length); console.log(fruits[0]); console.log(fruits[2]); // undefined console.log(fruits[fruits.length - 1]); Looping over an array // print all fruits // a. for for (let i = 0; i < fruits.length; i++) { console.log(fruits[i]); } // b. for of..
Objects one of the JavaScript's data types a collection of related data end/ or functionality Nearly all objects in JavaScript are instances of Object object = {key : value}; object는 key와 value의 집합체 Literals and properties const obj1 = {}; // 'object literal' syntax const obj2 = new Object(); // 'object constructor' syntax function print(person) { console.log(person.name); console.log(person.age..
javascript는 Object-Oriented Programming class: template object: instance of a class Javascript classes introduced in ES6 syntactical sugar over prototype-based inheritance 기존에 존재하던 prototype 기반으로 간편하게 쓸 수 있도록 문법만 class가 추가 Class declarations class Person { // constructor constructor(name, age) { //fields this.name = name; this.age = age; } // methods speak() { console.log(`${this.name}: hello!`)..
First-class function functions are treated like any other variable can be assigned as a value to variable can be passed as an argument to other functions can be returned by another function Function expression a function declaration can be called earlier than it is defined. (hoisted) 함수가 선언되기 이전에 호출해도 호출 가능 자바스크립트 엔진이 선언된 것을 제일 위로 올려주기 때문 a function expression is created when the execution reach..
let added in ES6 let name = 'jiwon'; console.log(name); name = 'hello'; console.log(name); var don't ever use this! 선언도 하기 전에 값 할당 가능 값 할당하기 전에도 출력 가능 (undefined) var hoisting move declaration from bottom to top 어디에 선언했냐에 상관없이 항상 제일 위로 선언을 끌어올려줌 has no block scope 블록을 이용해서 변수를 선언해도 어디에서나 볼 수 있음 age = 4; var age; constant 값을 할당한 다음에 다시는 변경 되지 않아야함 read only const daysInWeek = 7; const maxNumber =..