ES6 - Passing Arrays to Functions



The following example better explains this concept.

Example

var names = new Array("Mary","Tom","Jack","Jill") 
function disp(arr_names) {    
   for(var i = 0;i<arr_names.length;i++) {            
      console.log(names[i]) 
   } 
} 
disp(names)  

The following output is displayed on successful execution of the above code.

Output

Mary 
Tom 
Jack 
Jill
Advertisements