Resources Listed | Commented | Trie | Map | Simple | Recursive | JavaScript Implementation
Please do upvote, it motivates me to write more such posts\uD83D\uDE03\n\n\n\n// This class shows each and every node of trie\n\nclass Node{\n    constructor(){
**Please do upvote, it motivates me to write more such posts\uD83D\uDE03**\n\n```\n\n// This class shows each and every node of trie\n\nclass Node{\n    constructor(){\n        this.keys = new Map();\n        this.end = false;\n    }\n    setEnd(){this.end = true;}\n    isEnd(){return this.end}\n}\n\n// Simple initialization of the WordDictionary class\n\nvar WordDictionary = function() {\n    this.root = new Node();\n};\n\n// This just adds the word to the dictionary\n\nWordDictionary.prototype.addWord = function(word) {\n    let node = this.root;\n    function rec(node, word){\n        if(word){\n            if(!node.keys.has(word[0]))\n                node.keys.set(word[0], new Node());\n            return rec(node.keys.get(word[0]), word.substr(1));\n        }\n        else node.setEnd();\n    }\n    rec(node, word)\n    return true;\n};\n\n// This is the main recursive function where all of the magic is happening\n\nWordDictionary.prototype.search = function(word) {\n    let node = this.root;\n    function rec(node, word){\n\t\n\t\t// returns false if the node doesn\'t exist\n        if(!node) return false;\n\t\t\n\t\t// if the word exist\n        if(word){\n\t\t\n\t\t\t//skipping any calculation if the word[0] is . \n        \n\t\t\tif(word[0]===\'.\'){\n\t\t\t\t\n\t\t\t\t// Since we don\'t know what should be the next node so, need to go through all of them one by one\n                let out = false;\n                for(let val of node.keys.keys()){\n\t\t\t\t\t// Any one of the nodes will return true for the upcoming character in word after .\n\t\t\t\t\t// So, taking an OR operation\n                    out = out || rec(node.keys.get(val), word.substr(1));\n                }\n                return out;\n            }\n            else if(node.keys.has(word[0])){\n\t\t\t\t// If the node has encountered a word then the simple stuff\n                return rec(node.keys.get(word[0]), word.substr(1));\n            }\n\t\t\t// otherwise return false when the above two are false\n            else{ return false}\n            \n        }\n\t\t// If the word doesn\'t exist but it could have existed so just checking if the node is the end node and returning the result\n        else return node.isEnd();\n    }\n\t\n    return rec(node, word);\n};\n\n\n```\n\n**Following are some of the resources regarding *Trie***\n***JS based implementation of Trie*****Must checkout**\n[https://www.youtube.com/watch?v=7XmS8McW_1U](http://)\n\n\n***For more info about trie DS, you can watch the following video***\n*Copyright(For the following video): Tushar Roy*\n[https://www.youtube.com/watch?v=AXjmTQ8LEoI](http://)\n\n \n
['Recursion', 'JavaScript']