update default parameters transformer to use var a = arguments[0] === undefined ? 1 : arguments[0]; instead of if (a === undefined) a = 1;

This commit is contained in:
Sebastian McKenzie
2015-01-04 08:35:14 +11:00
parent 4d5861cfdc
commit cbcad22d81
6 changed files with 27 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
"use strict";
var some = function (count) {
if (count === undefined) count = "30";
var some = function () {
var count = arguments[0] === undefined ? "30" : arguments[0];
console.log("count", count);
};

View File

@@ -1,12 +1,12 @@
"use strict";
var t = function (t, f) {
if (t === undefined) t = "foo";
if (f === undefined) f = 5;
var t = function () {
var t = arguments[0] === undefined ? "foo" : arguments[0];
var f = arguments[1] === undefined ? 5 : arguments[1];
return t + " bar " + f;
};
var a = function (t, f) {
if (f === undefined) f = 5;
var a = function (t) {
var f = arguments[1] === undefined ? 5 : arguments[1];
return t + " bar " + f;
};

View File

@@ -1,6 +1,6 @@
"use strict";
var t = function (t) {
if (t === undefined) t = "foo";
var t = function () {
var t = arguments[0] === undefined ? "foo" : arguments[0];
return t + " bar";
};