Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript take any number of arguments

function sum() {
  // "arguments" is an object that can be converted to an Array
  const args = Array.from(arguments);
  return args.reduce((acc, next) => acc + next);
}

sum(1, 2);       // 3
sum(1, 2, 3);    // 6
sum(1, 2, 3, 4); // 10
Comment

Javascript function method with any number of arguments

function foo() {
  for (var i = 0; i < arguments.length; i++) {
    console.log(arguments[i]);
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: loop json jquery 
Javascript :: javascript format date yyyy-mm-dd 
Javascript :: print webpage in javascript 
Javascript :: nods js fs append to file 
Javascript :: javascript radio button change event 
Javascript :: javascript to convert rgb to hsl 
Javascript :: data-widget="pushmenu" collable automatically 
Javascript :: expo ignore warnings 
Javascript :: hemisphere light three js 
Javascript :: react native build apk 
Javascript :: regex char any quantity 
Javascript :: react router Link does work 
Javascript :: split words in javascript 
Javascript :: jquery append after 
Javascript :: angular cli add sslkey certificate 
Javascript :: how to check if a string is correctly encoded as base64 in javascript 
Javascript :: electron inspect 
Javascript :: matrix elements sum javascript 
Javascript :: quotes api 
Javascript :: date to seconds js 
Javascript :: hashtag strategy angular 
Javascript :: how to start json server 
Javascript :: remove special characters javascript 
Javascript :: regex min length max length 
Javascript :: get element property javascript 
Javascript :: react native curved view 
Javascript :: jquery find child of parent sibling 
Javascript :: uuid javascript 
Javascript :: error duplicate resources react native 
Javascript :: check if a class exists javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =