Key 기반 컬렉션에 대하여 출처 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Guide/Keyed_collections Map 객체 Map과 Set은 '입력된 순서대로' 접근 가능한 요소들을 포함하고 있다. Map객체에 저장되어 있는 각 요소들을 [키, 값] 형태의 배열로 반복적으로 반환해주는 for...of 를 사용할 수 있다. var sayings = new Map(); sayings.set("dog", "woof"); sayings.set("cat", "meow"); sayings.set("elephant", "toot"); sayings.size; // 3 sayings.get("a"); // undefined sayings.has("b");..
기본적인 배열 배열 생성 아래 구문들은 동일한 배열을 생성한다. const arr1 = new Array(a, b, ..., n); const arr2 = Array(a, b, ..., n); const arr3 = [a, b, ..., n]; 길이가 0이 아니지만 요소는 없는 배열 const arr1 = new Array(7); const arr2 = Array(7); const arr3 = []; arr3.length = 7; 객체의 속성에 배열 할당하기 const obj = {}; obj.prop = [a, b]; 또는 const obj = { prop: [a, b] }; obj.prop; // [a, b] 배열의 요소도 속성이므로 속성 접근자를 사용하여 접근할 수 있다. const arr = ["..
delete delete 연산자는 객체의 속성을 삭제한다. 구문 delete object.property; delete object[propertyKey]; delete objectName[index]; objectName : 객체 이름 property : 객체에 존재하는 속성 propertyKey : 존재하는 속성을 가리키는 문자열이나 심볼 반환값 delete 연산자로 삭제한 후 해당 속성에 접근할 경우 undefined 반환. 속성을 제거할 수 있는 경우에는 true를 반환하고, 제거할 수 없을 땐 false를 반환 예제 delete Math.PI; // false 반환 (설정 불가한 속성 삭제 불가) const myObj = { h: 4 }; delete myobj.h; // true 반환 dele..
Client-side storage Modern web browsers support a number of ways for websites to store data on the user's computer — with the user's permission — then retrieve it when necessary. This lets you persist data for long-term storage, save sites or documents for offline use, retain user-specific settings for your site, and more. This article explains the very basics of how these work. Client-side stor..
As a real-world example, think about the electricity supply in your house, apartment, or other dwellings. If you want to use an appliance in your house, you plug it into a plug socket and it works. You don't try to wire it directly into the power supply — to do so would be really inefficient and, if you are not an electrician, difficult and dangerous to attempt. Browser APIs are built into your ..
javascript 객체에 대하여 객체란? 객체는 관련된 데이터 아이템(프로퍼티)와 함수(메서드)의 집합이다. 객체는 각기 다른 이름(키)과 값(값)을 갖는 복수개의 멤버로 구성되며 이름과 값은 :으로 분리돤다. const person = { name: ["Bob", "Smith"], age: 32, gender: "male", interests: ["music", "skiing"], bio: function () { alert( this.name[0] + " " + this.name[1] + " is " + this.age + " years old. He likes " + this.interests[0] + " and " + this.interests[1] + ".", ); }, greeting: fu..