Default argument value helper

An example showing how to write helper for setting default value of the argument using Tizen 2.3.
var def = function(v, d) {
  return v === undefined ? d : v;
};

var test = function(a, b, c) {
  a = def(a, true);
  b = def(b, null);
  c = def(c, '123');

  console.log(a, b, c);
};

test();
test(false, 'x');

Responses

0 Replies