https://www.w3schools.com/js/js_const.asp
JavaScript const
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
www.w3schools.com
1) reassign 불가능하다.
const PI;
PI = 3.14159265359;
2) 그런데 , 객체의 property 속성은 변경이 가능하다.
// You can create a const object:
const car = {type:"Fiat", model:"500", color:"white"};
// You can change a property:
car.color = "red";
// You can add a property:
car.owner = "Johnson";
3) 또, 배열의 element 요소 변경이 가능하다.
// You can create a constant array:
const cars = ["Saab", "Volvo", "BMW"];
// You can change an element:
cars[0] = "Toyota";
// You can add an element:
cars.push("Audi");
4) 전체 변경은 불가능하다.
const car = {type:"Fiat", model:"500", color:"white"};
car = {type:"Volvo", model:"EX60", color:"red"}; // ERROR
'JavaScript' 카테고리의 다른 글
퇴근 후 JS - Arithmetic (산술) (0) | 2023.03.17 |
---|---|
퇴근 후 JS - Operators(연산자) (0) | 2023.03.17 |
퇴근 후 JS - Variables ( let, const) (0) | 2023.03.17 |
퇴근 후 JS - Statements (0) | 2023.03.16 |
퇴근 후 JS- 데이터 표현 방법(innerHTML, console.log(), alert()document.write(). (0) | 2023.03.16 |