Code&Data Insights
[Java Script] ECMAScript 5 & 6 본문
< JS ES5 version >
- "use strict"
: with strict mode, we can't use undeclared variables
- string index
str[0]
- string literal break up
" hello"
+ "hh"
=> return hello hh
- Able to use reserved words as property names
- Array reduce(), reduceRight() : sum of all numbers in an array
- Array every() : numbers.every(myFunction)
: function myFunction(value) {
return value > 18;
}
- Array indexOf(), lastIndexOf()
: lastIndexOf() works same as indexOf(), but searches from the end of the array.
-JSON.parse() : used to convert the text into a JS object
- JSON.stringify()
- Date.now() : same as getTime() on a Date Object
- toISOString() : converts a Date object to a string, using the ISO standard format
[ Property Getters and Setters ]
- Object.defineProperty()
[ E5 Object Methods ]
Managing Objects
- Accessing the prototype => Object.getPrototypeOf(object)
- ES5 allows trailing commas in object & array
BUT not in JSON!
< JS ES6 version >
- let
: allows to declare a variable with block scope
- const
: the value can't be changed
- Arrow Function
: NO need for function, return keyword
* NOT hoisted * = > MUST defined before they are used!
Using const is safer, since a function expression is always a constant value.
- Spread(...) Operator
: expands an iterable (like an array) into more elements
- Javascript Maps
: use an Object as a 'key'
- JavaScript Classes
: use the keyword class to a create a class.
* always add a method named 'constructor()'
[ Promise ]
: 동기화 관련
- 비동기 처리가 아닌 동기 처리로만 코드를 실행한다면, 특정 로직의 실행이 끝날때까지 기다리고 실행해야 하므로 웹 어플리케이션을 실행하는데 많은 시간이 걸림
- setTimeout() : web API의 한 종류
- jquery + callback 함수
=> callback 함수 : 데이터가 준비된 시점에서만 지정된 함수(동작)이 작동됨
[ async, await ]
reference : w3schools.com
'Web Development > Front-end' 카테고리의 다른 글
[Java Script] Asynchronous(비동기) Programming : Callback, Async/Await, Promise (0) | 2024.04.29 |
---|---|
[Redux] Redux, Flux Pattern (0) | 2024.04.28 |
[Event Loop Handling Technique] Throttling과 Debouncing (0) | 2024.04.27 |
[React] 컴포넌트(component), state, context API (0) | 2024.04.27 |
[Web] 웹의 역사와 기본 개념 : HTML, CSS, JavaScript의 역할 (0) | 2024.04.05 |