JavaScript
-
JavaScript 개요JavaScript 2021. 6. 19. 23:07
스크립트 언어란? 기본 프로그램의 동작을 사용자의 요구에 맞게 수행되도록 해주는 용도로 사용 됨. 매우 빠르게 배우고 짧은 소스코드 파일로 상호 작용하도록 고안되었음. Java Script 웹 브라우저에서 많이 사용하는 인터프리터 방식의 객체지향 프로그래밍 언어. ECMA 스크립트 표준을 따르는 대표적인 웹 기술. 작성 방법 소스는 함수 단위로 작성하고, 이벤트 속성을 사용해서 구동 되게 함. 이벤트 속성은 태그마다 차이가 있음. on이벤트명="실행할 함수명([전달값])" 1. inline 방식 태그에 직접 간단한 소스코드를 작성해서 실행 되게 하는 방법 경고창 출력 console 출력 마우스 오버 2. internal 방식 script 태그 영역에 작성해서 실행되게 하는 방법 head 태그, body ..
-
forEach & filter & map & sort & reduceJavaScript 2021. 6. 11. 01:48
const companies = [ {name: "Company One", category: "Finance", start: 1981, end: 2003}, {name: "Company Two", category: "Retail", start: 1992, end: 2008}, {name: "Company Three", category: "Auto", start: 1999, end: 2007}, {name: "Company Four", category: "Retail", start: 1985, end: 2010}, {name: "Company Five", category: "Technology", start: 2009, end: 2017}, {name: "Company Six", category: "Fin..
-
reduce()JavaScript 2021. 6. 11. 01:48
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next..
-
map()JavaScript 2021. 6. 10. 23:33
map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; Calls a defined callback function on each element of an array, and returns an array that contains the results. @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. @param thisArg An object to which the this keyword can r..
-
forEach()JavaScript 2021. 6. 10. 21:44
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; Performs the specified action for each element in an array. @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omi..
-
3. async & awaitJavaScript 2021. 6. 10. 19:36
API to make Promise seem concise, simple and synchronous clear style of using promise async is a syntactic sugar that makes Promise easier to use. 1. async async function fetchUser(){ return new Promise((resolve, reject) => { // do network request in 10 secs... resolve('lexie'); }) } const user = fetchUser(); user.then(console.log); if I put "async" keyword in front of the function, The code blo..
-
2. PromiseJavaScript 2021. 6. 10. 17:28
Promise is JavaScript object for asynchronous operfation. State : pending -> fulfilled or rejected Producer vs Consumer new Promise(executor) A Promise object is created using the new keyword and its constructor. 1. Producer // when new Promise is created, the executor runs automatically. const promise = new Promise((resolve, reject) => { // doing some heavy work (network, read files) console.lo..
-
1. callback function - Synchronous & AsynchronousJavaScript 2021. 6. 10. 14:07
JavaScript is synchronous. Execute the code block by orger after hoisting. hoisting: The declaration of a var or a function is lifted. Let's see an example console.log('1'); // -> sync setTimeout(() => console.log('2'), 1000); // -> async console.log('3'); // -> sync // Synchronous callback function printImmediately(print){ print(); } printImmediately(() => console.log('hello')); // -> sync // A..