Use the rest parameters instead of 'arguments'.
3535
3536function nuRemoveTabs (t) {
3537 for (let i = 0; i < arguments.length; i++) {
3538 $('#nuTab' + arguments[i]).remove()3539 }
3540}
3541
Use the rest parameters instead of 'arguments'.
3564
3565function nuHideTabs () {
3566 for (let i = 0; i < arguments.length; i++) {
3567 if (arguments[i] === parseInt(arguments[i], 10)) {3568 $('#nuTab' + arguments[i]).hide()
3569 } else {
3570 nuHideTabByTitle(arguments[i])
Use the rest parameters instead of 'arguments'.
3564
3565function nuHideTabs () {
3566 for (let i = 0; i < arguments.length; i++) {
3567 if (arguments[i] === parseInt(arguments[i], 10)) {3568 $('#nuTab' + arguments[i]).hide()
3569 } else {
3570 nuHideTabByTitle(arguments[i])
Use the rest parameters instead of 'arguments'.
3565function nuHideTabs () {
3566 for (let i = 0; i < arguments.length; i++) {
3567 if (arguments[i] === parseInt(arguments[i], 10)) {
3568 $('#nuTab' + arguments[i]).hide()3569 } else {
3570 nuHideTabByTitle(arguments[i])
3571 }
Use the rest parameters instead of 'arguments'.
3567 if (arguments[i] === parseInt(arguments[i], 10)) {
3568 $('#nuTab' + arguments[i]).hide()
3569 } else {
3570 nuHideTabByTitle(arguments[i])3571 }
3572 }
3573}
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'.
1343
1344function nuHideHolders (h) {
1345 for (let i = 0; i < arguments.length; i++) {
1346 if (arguments[i] == 0) { $('#nuActionHolder').hide() }1347 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').hide() }
1348 if (arguments[i] == 2) { $('#nuTabHolder').hide() }
1349 }
Use the rest parameters instead of 'arguments'.
1344function nuHideHolders (h) {
1345 for (let i = 0; i < arguments.length; i++) {
1346 if (arguments[i] == 0) { $('#nuActionHolder').hide() }
1347 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').hide() }1348 if (arguments[i] == 2) { $('#nuTabHolder').hide() }
1349 }
1350}
Use the rest parameters instead of 'arguments'.
1345 for (let i = 0; i < arguments.length; i++) {
1346 if (arguments[i] == 0) { $('#nuActionHolder').hide() }
1347 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').hide() }
1348 if (arguments[i] == 2) { $('#nuTabHolder').hide() }1349 }
1350}
1351
Use the rest parameters instead of 'arguments'.
1351
1352function nuRemoveHolders (h) {
1353 for (let i = 0; i < arguments.length; i++) {
1354 if (arguments[i] == 0) { $('#nuActionHolder').remove() }1355 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').remove() }
1356 if (arguments[i] == 2) { $('#nuTabHolder').remove() }
1357 }
Use the rest parameters instead of 'arguments'.
1352function nuRemoveHolders (h) {
1353 for (let i = 0; i < arguments.length; i++) {
1354 if (arguments[i] == 0) { $('#nuActionHolder').remove() }
1355 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').remove() }1356 if (arguments[i] == 2) { $('#nuTabHolder').remove() }
1357 }
1358}
Use the rest parameters instead of 'arguments'.
1353 for (let i = 0; i < arguments.length; i++) {
1354 if (arguments[i] == 0) { $('#nuActionHolder').remove() }
1355 if (arguments[i] == 1) { $('#nuBreadcrumbHolder').remove() }
1356 if (arguments[i] == 2) { $('#nuTabHolder').remove() }1357 }
1358}
1359
Use the rest parameters instead of 'arguments'.
1083 }
1084
1085 for (let a = 2; a < arguments.length; a++) {
1086 util.merge(target, arguments[a])1087 }
1088
1089 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.
}