
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
JavaScript Array length property
The Array length property set or returns the length of an array which is the number of total elements present in the given array.
Following is the code for the array length property −
Example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 20px; font-weight: 500; } </style> </head> <body> <h1>JavaScript Array length property</h1> <div class="sample"></div> <button class="Btn">CLICK HERE</button> <h3>Click on the above button to get the length of the array</h3> <script> let fillEle = document.querySelector(".sample"); let arr = ['H','E','L','L','O']; fillEle.innerHTML = arr; document.querySelector(".Btn").addEventListener("click", () => { fillEle.innerHTML = 'The length of the array is ' + arr.length; }); </script> </body> </html>
Output
On clicking the “CLICK HERE” button the array length will be shown −
- Related Articles
- JavaScript - length of array objects
- Length of a JavaScript associative array?
- Remove array duplicates by property - JavaScript
- Split number into n length array - JavaScript
- Length of shortest unsorted array in JavaScript
- How to find the length of jagged array using a property?
- Sorting JavaScript object by length of array properties.
- Splitting Number into k length array in JavaScript
- Replacing array of object property name in JavaScript
- jQuery length property
- Finding even length numbers from an array in JavaScript
- Maximum length of mountain in an array using JavaScript
- Add property to common items in array and array of objects - JavaScript?
- Sorting an array of objects by property values - JavaScript
- Sort array of objects by string property value - JavaScript

Advertisements