# How to pass array as arguments to function in javascript

You can pass array as arguments to function in javascript. You have to use the spread operator in javascript which pass the array elements as arguments to function. The number of arguments of function and array elements should be same.

• ## Pass array as arguments to multiply function using spread operator

``````<script>
function multiply(number1, number2, number3) {
console.log(number1 * number2 * number3);
}
let numbers = [1,2,3];
multiply(...numbers);
</script>
``````
0

Output:

`6`

This code snippet retuns the multiplication of the input parameters which is passed as array to function using spread operator. You have to pass the number of array elements which is equal to the number of parameters listed in the function definition.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7105013,"math_prob":0.9656795,"size":2050,"snap":"2022-27-2022-33","text_gpt3_token_len":423,"char_repetition_ratio":0.22091886,"word_repetition_ratio":0.050147492,"special_character_ratio":0.20731707,"punctuation_ratio":0.05882353,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99078435,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-15T01:15:45Z\",\"WARC-Record-ID\":\"<urn:uuid:45dc3b51-4713-4c45-91b2-2c9da483c638>\",\"Content-Length\":\"75542\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:febbf598-58e2-446b-9d5d-c42820ff84bf>\",\"WARC-Concurrent-To\":\"<urn:uuid:b009ca19-d344-4911-9592-6437b1362c95>\",\"WARC-IP-Address\":\"172.67.129.87\",\"WARC-Target-URI\":\"https://w3codegenerator.com/code-snippets/javascript/how-to-pass-array-as-arguments-to-function-in-javascript\",\"WARC-Payload-Digest\":\"sha1:FLMJQHRV5NLRMKM7OLZOIXJQFDB2BAPN\",\"WARC-Block-Digest\":\"sha1:ZXJXFSK5M55ARSHSRIRJKP3IATF3WZRV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882572089.53_warc_CC-MAIN-20220814234405-20220815024405-00642.warc.gz\"}"}