Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 스프링부트 회원가입
- springboot 미니프로젝트
- 스프링부트 update
- typescript 기초문법
- 파이썬 기초
- springboot 게시판
- 유니티Cube
- spring jpa 게시판
- springboot 게시판만들기
- 프로그래머스 괄호 회전하기 python
- 스프링게시판프로젝트
- python 괄호 회전하기
- 스프링부트 미니프로젝트
- 유니티
- 타입스크립트 기초
- 스프링부트 블로그
- 스프링부트 블로그만들기
- 유니티기초
- 스프링부트 게시판만들기
- 파이썬 괄호 회전하기
- spring jpa 사이드프로젝트
- JS기초
- 유니티Material
- springboot 게시판 프로젝트
- 스프링 게시판 만들기
- 괄호 회전하기 파이썬
- springboot 사이드프로젝트
- jpa 게시판
- 타입스크립트 기본문법
- 타입스크립트 기초문법
Archives
- Today
- Total
Digking's cave
JS 기초 ) 객체 메소드(Object methods) 본문
728x90
# 객체 메소드(Object methods)
Object.assign({},객체1,객체2...);
→ {}를 바탕으로 뒤에 객체를 복제한다.
const user = {
name : "happy",
age : 29,
};
const user2 = Object.assign({},user);
user2.name = "smile";
const user3 = Object.assign({gender:"female"},user);
console.log(user); // {name:"happy", age:29}
console.log(user2); // {name:"smile", age:29}
console.log(user3); // {gender: 'female', name: 'happy', age: 29}
Object.keys(객체);
→ 객체의 key를 배열로 반환
Object.values(객체);
→ 객체의 values를 배열로 반환
Object.entries(객체);
→ 객체의 key와 values를 배열로 반환
const resultKey = Object.keys(user);
const resultValue = Object.values(user);
const result = Object.entries(user);
console.log(resultKey); // ['name', 'age']
console.log(resultValue); // ['happy', 29]
console.log(result); // (2) [Array(2), Array(2)]
// 0: (2) ['name', 'happy']
// 1: (2) ['age', 29]
Object.fromEntries(배열);
→ 배열을 객체로 변환
let arr = [
['mon', '월'],
['tue', '화'],
]
const result = Object.fromEntries(arr);
console.log(result); // {mon: '월', tue: '화'}
반응형
'기초 > JavaScript' 카테고리의 다른 글
JS 기초 ) Array(배열메소드) - splice / slice / includes / find / map / join / split (0) | 2022.08.02 |
---|---|
JS 기초) 문자열 메소드 (문자열 길이 / 문자열 특정위치 / 문자열 비교/ 문자 대소문자 / 문자 위치찾기 / 특정문자 찾기) (0) | 2022.08.02 |
JS 기초 ) Number , Math (0) | 2022.08.01 |
JS 기초 ) 심볼 (Symbol) (0) | 2022.08.01 |
JS 기초 ) 계산된 프로퍼티 (Computed property) (0) | 2022.07.11 |