본문 바로가기

Front-end58

[JS] 배열 개념과 APIs 총정리 Array [Declaration] - 배열은 다양한 데이터타입을 담을 수 있다 하지만 여러 타입을 하나의 배열로 선언하는 것은 좋지 않은 방법이다. 'use strict'; // Array🎉 // 1. Declaration const arr1 = new Array(); const arr2 = [1, 2]; [Index position] - 인덱스는 0부터 시작 // 2. Index position const fruits = ['🍎', '🍌']; console.log(fruits); console.log(fruits.length); console.log(fruits[0]); console.log(fruits[1]); console.log(fruits[2]); //undefined console.log(f.. 2021. 8. 27.
[JS] 오브젝트 Objetct [Literals and properties] - object를 만드는 법 (1) object literal을 사용해서 생성 (2) object constructor을 이용해서 생성 - object는 추후에 property를 추가/삭제할 수 있다. - object는 key와 value의 집합체다. 'use strict'; // Objects // 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 }; //1. Literals an.. 2021. 8. 27.
[JS] 클래스와 오브젝트의 차이점, 객체지향 언어 클래스 정리 Class [class] - template, 청사진, 붕어빵 틀 - declare once - no data in [object] - instance of a class, 클래스에 데이터를 넣어서 만드는 것, 팥붕어빵,슈붕어빵 - created many times - data in [Class declaration] 'use strict'; // Object-oriendted programming // class: template // object: instance of a class // JavaScript classes // - introduced in ES6 // - syntactical sugar over prototype-based inheritance // 1. Class declaratio.. 2021. 8. 27.
[JS] Arrow Function, 함수의 선언과 표현 Function [Function] - 프로그램을 구성하는 기본적인 building block - subprogram으로도 불리며, 재사용이 가능 - 한가지의 task, 계산을 위해 사용됨 - Function의 이름, Input, Output이 중요하다 [Function declaration] - function name(param1, param2) { body... return; } - 하나의 함수는 한가지의 일만 수행하도록 작성해야한다. - 이름을 작성할때 doSomething, command, verb 와 같이 작성하기 - 함수는 object이기때문에 변수에 할당, 파라미터로 전달, 함수 리턴 가능 // 1. Function declaration // function name(param1, para.. 2021. 8. 27.
[JS] operator, if, for loop 코드리뷰 팁 Operator [String concatenation] - 기본적으로 ', "를 사용 - `을 사용해서 string literals를 생성가능, 줄바꿈이나 특수문자를 사용해도 문자열로 만들어짐 - 특수기호를 출력할때는 \를 앞에 붙여줘야한다. // 1. String concatenation console.log('my' + ' cat'); console.log('1' + 2); console.log(`string literals: 1 + 2 = ${1 + 2}`); [Numeric operators] // 2. Numeric operators console.log(1 + 1); // add console.log(1 - 1); // substract console.log(1 / 1); // divide .. 2021. 8. 27.
[JS] data types, let vs var, hoisting Variable 변수는 변경될 수 있는 값을 뜻한다. 읽고쓰기가 가능 [variable.js] //1. User strict //added in ES 5 //use this for Valina JavaSCript 'use strict'; // 2. Variable, rw(read/write) //let (added in ES6) let name = 'hellozo0'; console.log(name); name = 'hi'; console.log(name); Block Scope 1. Block scope : 블록 밖에서 블록 안에 있는 것들에 접근할 수 없음 2. Global scope : 어디서나 접근이 가능함, 어플리케이션이 실행되면서 끝날때까지 항상 메모리에 있기에 최소한으로 써야한다. [vari.. 2021. 8. 26.