💡JavaScript Solution - Trie + DFS
The idea\n1. Store words as trie\n2. Traverse trie using dfs\njavascript\n/**\n * Initialize your data structure here.\n */\nvar WordDictionary = function() {\n
### The idea\n1. Store words as `trie`\n2. Traverse `trie` using dfs\n``` javascript\n/**\n * Initialize your data structure here.\n */\nvar WordDictionary = function() {\n    this.trie = {};\n};\n\n/**\n * Adds a word into the data structure. \n * @param {string} word\n * @return {void}\n */\nWordDictionary.prototype.addWord = function(word) {\n    let root = this.trie;\n    for (let i=0;i<word.length;i++) {\n        if (root[word[i]]==null) root[word[i]] = {};\n        root = root[word[i]];\n    }\n    root.isEnd = true;  \n};\n\n/**\n * Returns if the word is in the data structure. A word could contain the dot character \'.\' to represent any one letter. \n * @param {string} word\n * @return {boolean}\n */\nWordDictionary.prototype.search = function(word) {\n    return this.dfs(word, 0, this.trie);\n};\n\nWordDictionary.prototype.dfs = function(word, index, node) {\n    if (index == word.length) return node.isEnd == true;\n    \n    if (word[index] == \'.\') {\n        for (let key in node) {\n            if (this.dfs(word, index + 1, node[key])) return true;\n        }\n        \n    } else {\n        if (node[word[index]]!=null) {\n            return this.dfs(word, index + 1, node[word[index]]);\n        }\n    }\n    return false;\n}\n\n\n/** \n * Your WordDictionary object will be instantiated and called as such:\n * var obj = new WordDictionary()\n * obj.addWord(word)\n * var param_2 = obj.search(word)\n */\n```
['JavaScript']