분류 전체보기27 [백투베이직 자바스크립트] Const? Let? Var? 어떤 걸 써야할까? 맨 처음 자바스크립트를 배울 때 (ES6 나오기 전), var만 있던 것을 기억한다. 그리고 ES6가 나오고 const와 let이 등장한 걸로 안다. VAR var가 function 밖에서 선언되었을 경우에는 코드 전역에서 변수가 자유롭게 변환이 가능하다. 만약 function 내에서 선언되었을 경우의 scope는 그 function 안으로 제한된다 - 즉 function 밖에서 var 변수를 쓸 수가 없다. 또한 var의 경우, 코드 전역에서 변수 변환이 가능하여 미리 선언된지 모른채 다시 사용하게 되었을 때는 문제가 발생할 수 있다. LET let의 경우, 이전 글 https://dongjindev.tistory.com/81 에서도 노트해놓았듯 block scoped라는 특징이 있다. 여기서 bloc.. 2022. 8. 4. Learning React.js React Components Creating a React component A component lets you put together a user interface with independent reusable pieces. A component is a function that returns some UI. Always, always, always, components need to be capitalized. import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; function Hello() { return ( Hello React! ); } ReactDOM.render( , document.getEl.. 2021. 3. 8. Learning ECMScript 6+ (ES6+) 2. Variables and Data Structures 1) let keyword - let is helping us enforce block scoping in JavaScript. // Example 1(1) - var var topic = "JavaScript"; if (topic) { var topic = "ECMAScript"; console.log("block", topic); } console.log("global", topic); // expected "global ECMAScript" // Example 1(2) - let var topic = "JavaScript"; if (topic) { let topic = "ECMAScript"; console.log("block", topic.. 2021. 2. 25. React JS - State & Lifecycle Why use class components instead of function components? - To use "state" class App extends React.Component{ state = { } render(){ return } } React automatically execute the render method inside of the class component. A state is an object. The data can be change (dynamic data). The number is: {this.state.count} Add Minus If you write "this.add()", the method will be executed immediately, not wh.. 2021. 2. 24. 이전 1 2 3 4 ··· 7 다음