@@ -61,6 +61,22 @@ declare module Immutable {
61
61
* arrays which pass `Array.isArray` to Lists, and only raw objects (no custom
62
62
* prototype) to Map.
63
63
*
64
+ * Keep in mind, when using JS objects to construct Immutable Maps, that
65
+ * JS object properties are always converted to strings, while Immutable Maps
66
+ * accept keys of any type.
67
+ *
68
+ * var obj = { 1: "one" };
69
+ * obj[1]; // "one"
70
+ * obj["1"]; // "one"
71
+ * Object.keys(obj); // [ "1" ]
72
+ *
73
+ * var map = fromJS(obj);
74
+ * map.get(1); // undefined
75
+ * map.get("1"); // "one"
76
+ *
77
+ * Property access for JS objects converts the key to a string, but Map keys
78
+ * can be of any type, so the argument to `get()` is not converted.
79
+ *
64
80
* [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter
65
81
* "Using the reviver parameter"
66
82
*/
@@ -404,6 +420,21 @@ declare module Immutable {
404
420
* var newMap = Map({key: "value"});
405
421
* var newMap = Map([["key", "value"]]);
406
422
*
423
+ * Keep in mind, when using JS objects to construct Immutable Maps, that
424
+ * JS object properties are always converted to strings, while Immutable Maps
425
+ * accept keys of any type.
426
+ *
427
+ * var obj = { 1: "one" };
428
+ * obj[1]; // "one"
429
+ * obj["1"]; // "one"
10000
430
+ * Object.keys(obj); // [ "1" ]
431
+ *
432
+ * var map = Map(obj);
433
+ * map.get(1); // undefined
434
+ * map.get("1"); // "one"
435
+ *
436
+ * Property access for JS objects converts the key to a string, but Map keys
437
+ * can be of any type, so the argument to `get()` is not converted.
407
438
*/
408
439
export function Map < K , V > ( ) : Map < K , V > ;
409
440
export function Map < K , V > ( iter : KeyedIterable < K , V > ) : Map < K , V > ;
0 commit comments