HOLLA TECH - LEARN

The length Property
 

JavaScript arrays have useful built-in properties and methods.

An array’s length property returns the number of it’s elements. 

var courses = [“HTML”, “CSS”, “JS”];
document.write(courses.length);
//Outputs 3 

 

NOTE!
The length property is always one more than the highest array index. If the array is empty, the length property returns 0.

Combining Arrays
 

JavaScript’s concat() method allows you to join arrays and create an entirely new array.

Example:

var c1 = [“HTML”, “CSS”];
var c2 = [“JS”, “C++”];
var courses = c1.concat(c2);

  

The courses array that results contains 4 elements (HTML, CSS, JS, C++).  

NOTE!
The concat operation does not affect the c1 and c2 arrays – it returns the resulting concatenation as a new array.

BACK NEXT

CLICK ON THE BUTTON BELOW TO GO TO THE JAVASCRIPT MAIN COURSE PAGE. 

JAVASCRIPT MAIN COURSE PAGE

 


© License: All Rights Reserved 


CONTACT HOLLA TECH – LEARN SUPPORT