title: Shortest way (one-liner) to get a default argument out of a v8 function?
body: <p>It's been a long time since I've used C++, and even longer since I wrapped my head around hard types. I'm simply looking for a <strong>working</strong> one liner to do get an argument from v8, or a default value when an argument wasn't supplied.</p>
  
  <pre><code>v8::String::Utf8Value arg0(args[0]);
  v8::String::Utf8Value arg1(args[1]);
  v8::String::Utf8Value arg2(args[2]);
  const char *username = (args.Length() &gt; 0) ? *arg0 : "";
  const char *password = (args.Length() &gt; 1) ? *arg1 : "";
  const char *service = (args.Length() &gt; 2) ? *arg2 : "login";
  </code></pre>
  
  <p>Outputs:</p>
  
  <pre>
  func(); // { username: "", password: "", service: "login" }
  func('1'); // { username: "1", password: "", service: "login" }
  func('1', '2'); // { username: "1", password: "2", service: "login" }
  func('a', 'b', 'c'); // { username: "a", password: "b", service: "c" }
  </pre>
  
  <p>Unfortunately, the following close-to-ideal solution doesn't work for me (any ideas why?):</p>
  
  <pre><code>const char *username = (args.Length() &gt; 0) ? *v8::String::Utf8Value(args[0]-&gt;ToString()) : "";
  const char *password = (args.Length() &gt; 1) ? *v8::String::Utf8Value(args[1]-&gt;ToString()) : "";
  const char *service = (args.Length() &gt; 2) ? *v8::String::Utf8Value(args[2]-&gt;ToString()) : "login";
  </code></pre>