프론트엔드 센트럴파크 (☞゚ヮ゚)☞

원시(Primitive)값과 객체 본문

Javascript

원시(Primitive)값과 객체

자라나라나무나무나 2022. 5. 28. 18:13

원시 값 : 불변하다

- undefined

- Boolean

- String

- Number

- Bigint

- Symbol

const test = 'string';
console.log(test.toUpperCase());
console.log(test);

변경된 값을 return 하고 싶으면 재할당을 해주면 된다.

let test = 'string';
test = test.toUpperCase();
console.log(test);


객체 : 변경가능한 값

- const object = {};

- const array = [];

- const func() {}

let person = {
    name : "Park"
};

// 프로퍼티 값 갱신
person.name = "Kim";

// 프로퍼티 동적 생성
person.address = "Busan";

console.log(person);

객체는 재할당 없이 프로퍼티를 동적으로 추가할 수도 있고 프로퍼티 값을 갱신할 수도 있으며, 프로퍼티를 삭제할 수도 있다.

 

 

'Javascript' 카테고리의 다른 글

Map() - 반복문  (0) 2022.05.28
Map() - 추가, 접근, 삭제  (0) 2022.05.28
Number.isNan() - NaN을 판별할 때  (0) 2022.05.28
생성자 함수  (0) 2022.05.27
고차함수 - reduce()  (0) 2022.05.27
Comments