-
for 반복문(of / in 사용법)프로그래밍 공부 메모/nodejs 2023. 6. 25. 21:04
for 반복문 사용시 배열 데이터에서 'of' 사용
const users = [{name : 'heropy',age : 85},{name : 'neo',age : 22},{name : 'lewis',age : 34},]
for(let i = 0 ; i<users.length ; i++){console.log(users[i])}
for(const user of users){console.log(user)}
객체 데이터를 for문으로 작성시 'in' 사용
const user = {name : 'heropy',age : 85,isValid : true,email : 'test@gmail.com'}
for (const key in user){console.log(key)}반응형'프로그래밍 공부 메모 > nodejs' 카테고리의 다른 글
javascript event loop 동작 흐림도 (0) 2023.08.19 PM2 - Node.js 프로세스 관리 도구 (0) 2023.08.19 javascript 반복문 예제 (0) 2023.08.13 매개변수 패턴 - 구조 분해 할당(객체 / 배열) (0) 2023.06.25 ?? 연산자 (0) 2023.06.25