객체 리터럴 2가지 표현 방식의 차이점
JavaScript에서 객체 리터럴을 사용할 때, 속성(property) 이름을 표기하는 방식에 대해 두 가지 방법이 있습니다: 1. 식별자(identifier) 이름처럼 속성 이름을 사용하는 경우 (따옴표 없이)let sports = { Baseball: ['Seoul', 'Daegu'], Basketball: [ 'Suwon', 'Busan', 'Ulsan'], Football : 'Seoul'}for (let sport in sports) { console.log(sport)}// Baseball// Basketball// Footballlet obj = { name: "John", age: 30, $salary: 5000, _department: "IT", ..
JavaScript
2024. 9. 30. 20:12