Use the rest parameters instead of 'arguments'.
3514 if (arguments[i] === parseInt(arguments[i], 10)) {
3515 $('#nuTab' + arguments[i]).hide()
3516 } else {
3517 nuHideTabByTitle(arguments[i])3518 }
3519 }
3520}
Use the rest parameters instead of 'arguments'.
3512function nuHideTabs () {
3513 for (let i = 0; i < arguments.length; i++) {
3514 if (arguments[i] === parseInt(arguments[i], 10)) {
3515 $('#nuTab' + arguments[i]).hide()3516 } else {
3517 nuHideTabByTitle(arguments[i])
3518 }
Use the rest parameters instead of 'arguments'.
3511
3512function nuHideTabs () {
3513 for (let i = 0; i < arguments.length; i++) {
3514 if (arguments[i] === parseInt(arguments[i], 10)) {3515 $('#nuTab' + arguments[i]).hide()
3516 } else {
3517 nuHideTabByTitle(arguments[i])
Use the rest parameters instead of 'arguments'.
3511
3512function nuHideTabs () {
3513 for (let i = 0; i < arguments.length; i++) {
3514 if (arguments[i] === parseInt(arguments[i], 10)) {3515 $('#nuTab' + arguments[i]).hide()
3516 } else {
3517 nuHideTabByTitle(arguments[i])
Use the rest parameters instead of 'arguments'.
3482
3483function nuRemoveTabs (t) {
3484 for (let i = 0; i < arguments.length; i++) {
3485 $('#nuTab' + arguments[i]).remove()3486 }
3487}
3488
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.
}