목록CS (38)
juni
새로운 Promise를 생성 시 동기적 동작 / Promise 결과에 접근 시 비동기적으로 동작const fetchData = async () => { let response = await (await fetch("")).json();};// Promise 객체 생성const promise = new Promise((resolve, reject) => { if (true) { resolve("성공데이터"); } else { reject("실패데이터"); }});// Promise에 resolve데이터 접근promise.then((resolve) => { console.log(resolve);});// Promise에 reject데이터 접근promise.catch((reject) => ..
Attribute 와 Property 차이점Attribute : HTML의 속성 , element에 id / class 와 같은 추가적인 정보 , 정적임Property : DOM의 속성 , 동적임둘이 연결은 되어있지만 Property값을 변경하면 DOM객체만 업데이트 되고 HTML은 업데이트 되지 않아Attribute 값은 그대로임 // Destructuring 구조분해할당// 배열은 위치(index) , 객체는 key가 중요함const person = { name: "르탄이", age: 25, job: "개발자",};const { name, age } = person;console.log(`hi ${name}!, ${age}!!`);const movie = { title: "inception",..
let , const, var// let const는 블록단위 스코프let blockScopeVariable = "Available only in this block";if (true) { let blockedScope = "Visible inside this block"; console.log(blockedScope);}// 아래 주석 코드는 스코프 오류로 실행X// console.log(blockedScope)console.log(blockScopeVariable);for (let i = 0; i 3; i++) { console.log(i);}function testFunction() { let test = "any words"; if (true) { test = "changed va..

State와Props 활용import "./App.css";import { useState } from "react";import Bulb from "./components/Bulb";import Counter from "./components/Counter";//함수 컴포넌트 리랜더링 -> App함수 재호출하고 바뀐 값을 재랜더링//자신이 관리하는 state 값 변경시 , 자신이 제공 받는 props값이 변경시//부모 component 리랜더링시 자신도 리랜더링 -> 위 3가지 경우 리랜더링// 컴포넌트를 나누어 불필요한 리랜더링 방지function App() { return ( Bulb /> Counter /> );}export default App; import ..
//콜백 함수 -> 다른 코드의 인자로 넘겨주는 함수// setTimeout(function () {// console.log("hi")// },1000)const numbers = [1, 2, 3, 4, 5];numbers.forEach(function (number) { console.log(number);});//제어권 / 호출 시점에대한 제어권을 갖는다.//setInterval() : 반복해서 매개변수로 받은 콜백함수의 로직을 수행let conut = 0;let cbFunc = function () { console.log(conut); if (++conut > 4) clearInterval(timer);};//setInterval의 반복을 멈추기위한 timer 선언let timer ..