Jump to content

JavaScript: Difference between revisions

129 bytes added ,  23 January 2020
Line 112: Line 112:
===Objects===
===Objects===
Objects are maps in JavaScript. They are typically implemented as hashmaps by the JS engine.<br>
Objects are maps in JavaScript. They are typically implemented as hashmaps by the JS engine.<br>
Note that you can only use numbers and strings as keys.
Note that you can only use numbers and strings as keys.<br>
Learn more about the implementation at [https://v8.dev/blog/hash-code https://v8.dev/blog/hash-code]<br>
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
let my_map = {};
let my_map = {};
my_map["my_key"] = "my_value";
// or my_map["my_key"]
my_map.my_key = "my_value";
"my_key" in my_map;
"my_key" in my_map;