Would you please help me to know about the LOOP, how we got the 'arguments'? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Would you please help me to know about the LOOP, how we got the 'arguments'?

function containsAll(arr) { for (let k = 1; k < arguments.length; k++) { let num = arguments[k]; if (arr.indexOf(num) === -1) { return false; } } return true; } let x = [2, 4, 6, 7]; console.log(containsAll(x, 2, 4, 7)); console.log(containsAll(x, 6, 4, 9));

18th Jan 2023, 5:57 AM
Sony
Sony - avatar
3 Answers
+ 4
In JS, 'arguments' is a local variable within functions, which you can use to access the arguments you have passed to a function. It is an implicitly-declared binding, which means that you don't have to declare it yourself to use it. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
18th Jan 2023, 6:57 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
Hatsy Rei Thank you so much.. :)
18th Jan 2023, 8:36 AM
Sony
Sony - avatar
0
Hatsy Rei again needed to know, why here is used let variable's 'x' as expression in the console to print out the output ?
18th Jan 2023, 1:30 PM
Sony
Sony - avatar