javascript - Passing the elements of an array as argument list to a function (not as a combined string) -
I have a customized (console.) Log function
function clog ( ToConsole, toFile) {Console.log (toConsole); // other things} But now I call it 'value:% d', value format ... until I get it Do not wrap any array
(['console:% d', value], 'other things']) Is that a way Is a way to pass the elements of the array : Function such as: console:% d, value] : console.log ('console:% d', value)
What you are searching for is that it allows you to call a function with an array That is B logic is loaded as. In this case
console.log.apply (console, ['console:% d', value]);
will be equal to console.log ('console:% d', value);
Comments
Post a Comment