“JS -Funktionsargumente” Code-Antworten

JS nicht spezifizierte Parameter

function my_log(...args) {
     // args is an Array
     console.log(args);
     // You can pass this array as parameters to another function
     console.log(...args);
}
Bright Booby

Argumente Objekt in JavaScript

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

addAll(1, 2, 3, 4, 5, 6, 7, 8, 9,10); //we can provide inifite numbers as argument
Ainul Sakib

JS -Funktionsargumente

                          An Example of a function argument


function printValue(someValue) {
    console.log('The item I was given is: ' + someValue);
}

printValue('abc'); // -> The item I was given is: abc
Doubtful Dunlin

Javascript -Funktionsparameter

function printValues(value1, value2) {
    console.log(value1 + ', ' + value2);
}

printValues('abc', 123); // -> abc, 123
Doubtful Dunlin

Ähnliche Antworten wie “JS -Funktionsargumente”

Fragen ähnlich wie “JS -Funktionsargumente”

Weitere verwandte Antworten zu “JS -Funktionsargumente” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen