From c87b96527998f2e95ee9915bb439963b3aeb0888 Mon Sep 17 00:00:00 2001 From: Steeve Vadakkumchery <45942491+steevevadakkumchery@users.noreply.github.com> Date: Fri, 31 May 2019 01:22:46 +0100 Subject: [PATCH 1/2] Updated chapter 3 - Contents section Proposed a change in the text to say that when Symbols are used as keys in objects, it's not coerced into a string primitive. ``` var obj = {} var firstSymbol = Symbol('hello'); var secondSymbol = Symbol('hello'); console.log(firstSymbol); // Symbol(hello) console.log(secondSymbol); // Symbol(hello) obj[firstSymbol] = 'first value'; obj[secondSymbol] = 'second value'; console.log(obj[firstSymbol]); // first value console.log(obj[secondSymbol]); // second value console.log(obj["Symbol(hello)"]) // undefined ``` --- this & object prototypes/ch3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/this & object prototypes/ch3.md b/this & object prototypes/ch3.md index 8821d862e..820ea3266 100644 --- a/this & object prototypes/ch3.md +++ b/this & object prototypes/ch3.md @@ -146,7 +146,7 @@ if (wantA) { console.log( myObject[idx] ); // 2 ``` -In objects, property names are **always** strings. If you use any other value besides a `string` (primitive) as the property, it will first be converted to a string. This even includes numbers, which are commonly used as array indexes, so be careful not to confuse the use of numbers between objects and arrays. +In objects, property names are `strings` expect when using the primitive type `symbol`. If you use any other values besides `string` or `symbol` (primitives) as the property, it will first be converted to a string. This even includes numbers, which are commonly used as array indexes, so be careful not to confuse the use of numbers between objects and arrays. ```js var myObject = { }; From 6583e29331f9a624eb2e71edeee9f47b1b16fa40 Mon Sep 17 00:00:00 2001 From: Steeve Vadakkumchery <45942491+steevevadakkumchery@users.noreply.github.com> Date: Fri, 31 May 2019 11:25:10 +0100 Subject: [PATCH 2/2] fixed typo in PR Fixed typo in PR --- this & object prototypes/ch3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/this & object prototypes/ch3.md b/this & object prototypes/ch3.md index 820ea3266..9c03ee369 100644 --- a/this & object prototypes/ch3.md +++ b/this & object prototypes/ch3.md @@ -146,7 +146,7 @@ if (wantA) { console.log( myObject[idx] ); // 2 ``` -In objects, property names are `strings` expect when using the primitive type `symbol`. If you use any other values besides `string` or `symbol` (primitives) as the property, it will first be converted to a string. This even includes numbers, which are commonly used as array indexes, so be careful not to confuse the use of numbers between objects and arrays. +In objects, property names are `string` except when using the primitive type `symbol`. If you use any other values besides `string` or `symbol` (primitives) as the property, it will first be converted to a string. This even includes numbers, which are commonly used as array indexes, so be careful not to confuse the use of numbers between objects and arrays. ```js var myObject = { };