title: A custom javascript document.getElementById() method?
body: <p>I have tried out a custom getElementById() method to retrieve DOM element from a HTML page. This is the definition.</p>
  
  <pre><code>document.customGetElById = function(passedId){
      var nodeFound = null;
      recursive = function(nodes)
      {
          for(var i =0 ; i&lt; nodes.length; i++)
          {
              if(nodes[i].nodeType == 1) //element nodes
              {
                  //console.log(nodes[i].id);   //only element nodes have id's
                  if(nodes[i].id == passedId)
                  {
                      //console.log(nodes[i]);
                      nodeFound = nodes[i];
                      return;
                  }
                  if(nodes[i].childNodes)
                  {
                      //console.log('there are child nodes inside it');
                      recursive(nodes[i].childNodes);
                  }
              }
          }
      }
      recursive(document.body.childNodes);
      return nodeFound;
  };
  </code></pre>
  
  <p>Is this a correct way of doing it? Is this good for performance?
  It has nothing to do to override the native getElementById() method. How is the native function written? Can somebody help me out? 
  Thanks in advance.</p>