title: Object type is the name of the String rather than the String itself when working with process.argv in Node
body: <p>I'm working with Node, and I'm attempting to use a parameter passed in via the command line as a string. My current code is:</p>
  
  <pre><code>if (process.argv.length &gt; 2) {
          var domain = process.argv[DOMAIN_ARGV];
          if (domain != null) {
              checkdomain(domain);
          }
  </code></pre>
  
  <p>I then use checkDomain(domain) to strip the prefix off of the domain with:</p>
  
  <pre><code>// Strip off http, https, and www from domains
  domain = domain.replaceAll("(http://|http://www\\.|https://|https://www\\.|www\\.)", "");
  </code></pre>
  
  <p>However, domain is not being treated as a String. Rather, domain's type is the value of the String itself. If I pass in example.com as my domain, I get:</p>
  
  <pre><code>user@ubuntu-laptop:~/src$ node lookup.js example.com
  
  /home/user/src/lookup.js:29
      domain = domain.replaceAll(
                            ^
  TypeError: Object example.com has no method 'replaceAll'
      at checkdomain (/home/user/src/lookup.js:29:24)
      at lookup (/home/user/src/lookup.js:19:4)
      at Object.&lt;anonymous&gt; (/home/user/src/lookup.js:63:2)
      at Module._compile (module.js:456:26)
      at Object.Module._extensions..js (module.js:474:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Function.Module.runMain (module.js:497:10)
      at startup (node.js:119:16)
      at node.js:902:3
  </code></pre>
  
  <p>The type should be a String, not example.com (or whatever other argument has been passed in). Does anyone know of a solution to this problem?</p>