From 6708e2a3028b6b8810539a88554df799e2108008 Mon Sep 17 00:00:00 2001 From: Steve Kinney Date: Sat, 7 May 2016 08:52:52 -0600 Subject: [PATCH] :lipstick: Cache last argument in parseArgs This is to eliminate the need to access the array twice. --- lib/browser/api/dialog.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/browser/api/dialog.js b/lib/browser/api/dialog.js index 6669d8cab89a..3410618027fe 100644 --- a/lib/browser/api/dialog.js +++ b/lib/browser/api/dialog.js @@ -35,8 +35,9 @@ var parseArgs = function (window, options, callback, ...args) { } // Fallback to using very last argument as the callback function - if ((callback == null) && typeof args[args.length - 1] === 'function') { - callback = args[args.length - 1] + var lastArgument = args[args.length - 1] + if ((callback == null) && typeof lastArgument === 'function') { + callback = lastArgument } return [window, options, callback]