From fd192ff318b22e886d0c9cea645e9aecbfa27678 Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Tue, 6 May 2014 09:56:01 -0700 Subject: [PATCH] Better dfl implementation --- moment.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/moment.js b/moment.js index c0070c93f..a26528686 100644 --- a/moment.js +++ b/moment.js @@ -283,14 +283,14 @@ lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin']; - function dfl() { - var i; - for (i = 0; i < arguments.length; ++i) { - if (arguments[i] != null) { - return arguments[i]; - } + // Pick the first defined of two or three arguments. dfl comes from + // default. + function dfl(a, b, c) { + switch (arguments.length) { + case 2: return a != null ? a : b; + case 3: return a != null ? a : b != null ? b : c; + default: throw new Error("Implement me"); } - return null; } function defaultParsingFlags() { -- 2.47.2