본문 바로가기

Front-end/Javacript

(28)
DOM image 출처 : https://simplesnippets.tech/what-is-document-object-modeldom-how-js-interacts-with-dom/
Javascript | Fetch vs Axios 차이점 비교 Javascript에서 HTTP Requests 를 위한 방법에는 Fetch 와 Axios 두가지가 있습니다. Fetch 가 Built-in APIs 로서 별도의 설치 없이 모던 브라우저에서 사용이 가능하지만, Axios 가 사용하기 쉽고 브라우저 하위 호환성 등 몇몇 이유로 인해 개발자들 사이에서 많이 사용이 되고 있는데요. 네이티브 APIs 를 선호하는 개발자라면 Fetch 를 별도의 설치나 임포트 없이 사용하고 싶어 할 것입니다. 그러나 Axios 에서 쉽게 구현이 가능한 기능들에 대해서 Fetch에서는 기본적으로는 제공이 되지 않거나, 추가적인 로직 구현이 필요한 것들도 있어 Axios를 사용하는 경우도 많은 것 같은데요. 그래서 Fetch 와 Axios 에 대한 각각의 특징과 어떤 차이점이 있는..
JavaScript 이벤트 처리 속성 정리
JavaScript - Map() map은 forEach와 마찬가지로 Array의 각 요소를 순회하며 callback 함수를 실행합니다. 다만, callback에서 return 되는 값을 배열로 만들어냅니다. 1. [].map(callback, thisArg) 기본적인 map의 사용법은 아래와 같습니다. const arr = [0,1,2,3]; let squaredArr = arr.map(function(element){ return element * element; }); // 혹은 arrow 함수 가능 squaredArr = arr.map(element => element * element); console.log(squaredArr); // [ 0, 1, 4, 9 ] 위 코드를 보면 배열 속 숫자들이 제곱되어 새로운 배열이 생성되는..
Arrow Functions ES6 introduced arrow function syntax, a shorter way to write functions by using the special “fat arrow” () => notation. Arrow functions remove the need to type out the keyword function every time you need to create a function. Instead, you first include the parameters inside the ( ) and then add an arrow => that points to the function body surrounded in { } like this: const rectangleArea = (widt..
Return When a function is called, the computer will run through the function’s code and evaluate the result of calling the function. By default that resulting value is undefined. function rectangleArea(width, height) { let area = width * height; } console.log(rectangleArea(5, 7)) // Prints undefined In the code example, we defined our function to calculate the area of a width and height parameter. Then..
Parameters and Arguments some functions can take inputs and use the inputs to perform a task. When declaring a function, we can specify its parameters. Parameters allow functions to accept input(s) and perform a task using the input(s). We use parameters as placeholders for information that will be passed to the function when it is called. Let’s observe how to specify parameters in our function declaration: In the diagr..
Calling a Function a function declaration does not ask the code inside the function body to run, it just declares the existence of the function. The code inside a function body runs, or executes, only when the function is called. To call a function in your code, you type the function name followed by parentheses. This function call executes the function body, or all of the statements between the curly braces in th..