Skip to content

Use of Maps for enumerating names of elements and their physical properties #55

Answered by samreid
dave-english asked this question in Q&A
Discussion options

You must be logged in to vote

According to https://caniuse.com/mdn-javascript_builtins_map_map_iterable_allowed, IE11 still does not support the new Map(iterable) constructor, which takes a parameter on construction, like so:

var myMap = new Map([['key1', 'value1'], ['key2', 'value2']]);

According to https://phet.colorado.edu/en/help-center/running-sims, PhET itself no longer supports IE11, but other teams may have other requirements.

Here are a few ways to associate names and physical constants:

// Simple map with key/value pairs
const elements1 = {
  Hydrogen: 'H',
  Helium: 'He',
  Lithium: 'Li'
};

// Richer value type
const elements2 = {
  Hydrogen: {
    symbol: 'H',
    atomicNumber: 1
  },
  Helium: {
    symbol

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dave-english
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants