Use the rest parameters instead of 'arguments'.
3514
3515function nuRemoveTabs (t) {
3516 for (let i = 0; i < arguments.length; i++) {
3517 $('#nuTab' + arguments[i]).remove()3518 }
3519}
3520
Use the rest parameters instead of 'arguments'.
3543
3544function nuHideTabs () {
3545 for (let i = 0; i < arguments.length; i++) {
3546 if (arguments[i] === parseInt(arguments[i], 10)) {3547 $('#nuTab' + arguments[i]).hide()
3548 } else {
3549 nuHideTabByTitle(arguments[i])
Use the rest parameters instead of 'arguments'.
3543
3544function nuHideTabs () {
3545 for (let i = 0; i < arguments.length; i++) {
3546 if (arguments[i] === parseInt(arguments[i], 10)) {3547 $('#nuTab' + arguments[i]).hide()
3548 } else {
3549 nuHideTabByTitle(arguments[i])
Use the rest parameters instead of 'arguments'.
3544function nuHideTabs () {
3545 for (let i = 0; i < arguments.length; i++) {
3546 if (arguments[i] === parseInt(arguments[i], 10)) {
3547 $('#nuTab' + arguments[i]).hide()3548 } else {
3549 nuHideTabByTitle(arguments[i])
3550 }
Use the rest parameters instead of 'arguments'.
3546 if (arguments[i] === parseInt(arguments[i], 10)) {
3547 $('#nuTab' + arguments[i]).hide()
3548 } else {
3549 nuHideTabByTitle(arguments[i])3550 }
3551 }
3552}
Use the rest parameters instead of 'arguments'.
117
118String.prototype.nuFormat = function () {
119 let args
120 args = arguments 121 if (args.length === 1 && args[0] !== null && typeof args[0] === 'object') {
122 args = args[0]
123 }
Use the rest parameters instead of 'arguments'.
1340
1341function nuHideHolders (h) {
1342 for (let i = 0; i < arguments.length; i++) {
1343 if (arguments[i] == 0) { $('#nuActionHolder').hide() }1344 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').hide() }
1345 if (arguments[i] == 2) { $('#nuTabHolder').hide() }
1346 }
Use the rest parameters instead of 'arguments'.
1341function nuHideHolders (h) {
1342 for (let i = 0; i < arguments.length; i++) {
1343 if (arguments[i] == 0) { $('#nuActionHolder').hide() }
1344 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').hide() }1345 if (arguments[i] == 2) { $('#nuTabHolder').hide() }
1346 }
1347}
Use the rest parameters instead of 'arguments'.
1342 for (let i = 0; i < arguments.length; i++) {
1343 if (arguments[i] == 0) { $('#nuActionHolder').hide() }
1344 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').hide() }
1345 if (arguments[i] == 2) { $('#nuTabHolder').hide() }1346 }
1347}
1348
Use the rest parameters instead of 'arguments'.
1348
1349function nuRemoveHolders (h) {
1350 for (let i = 0; i < arguments.length; i++) {
1351 if (arguments[i] == 0) { $('#nuActionHolder').remove() }1352 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').remove() }
1353 if (arguments[i] == 2) { $('#nuTabHolder').remove() }
1354 }
Use the rest parameters instead of 'arguments'.
1349function nuRemoveHolders (h) {
1350 for (let i = 0; i < arguments.length; i++) {
1351 if (arguments[i] == 0) { $('#nuActionHolder').remove() }
1352 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').remove() }1353 if (arguments[i] == 2) { $('#nuTabHolder').remove() }
1354 }
1355}
Use the rest parameters instead of 'arguments'.
1350 for (let i = 0; i < arguments.length; i++) {
1351 if (arguments[i] == 0) { $('#nuActionHolder').remove() }
1352 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').remove() }
1353 if (arguments[i] == 2) { $('#nuTabHolder').remove() }1354 }
1355}
1356
Use the rest parameters instead of 'arguments'.
1079 }
1080
1081 for (let a = 2; a < arguments.length; a++) {
1082 util.merge(target, arguments[a])1083 }
1084
1085 return target
Description
There are rest parameters in ES2015
. We can use that feature for variadic functions instead of the arguments
variable.
arguments
does not have methods of Array.prototype
, so it's a bit of an inconvenience.
Bad Practice
function foo() {
console.log(arguments);
}
function foo(action) {
var args = Array.prototype.slice.call(arguments, 1);
action.apply(null, args);
}
function foo(action) {
var args = [].slice.call(arguments, 1);
action.apply(null, args);
}
Recommended
function foo(...args) {
console.log(args);
}
function foo(action, ...args) {
action.apply(null, args); // or `action(...args)`, related to the `prefer-spread` rule.
}
// Note: the implicit arguments can be overwritten.
function foo(arguments) {
console.log(arguments); // This is the first argument.
}
function foo() {
var arguments = 0;
console.log(arguments); // This is a local variable.
}