title: How do I fix the error '.has is not a function' when using JavaScript Map?
body: <p>I have the following code that attempts to set a value in a Map:</p>
  <pre><code>class Trie {
    constructor () {
      this.trie = new Map()
    }
  
    insert(word) {
      let current = this.trie
      for (let alpha of word) {
        if (!current.has(alpha)) current.set(alpha, [])
        current = current.get(alpha)
      }
      current.word = word
    }
  }
  
  let trie = new Trie()
  trie.insert('test')
  console.log(trie.trie)
  </code></pre>
  <p>When I attempt to run it, I get the error <code>.has is not a function</code>. What am I missing here?</p>