Java/J2EE and SOA (349 Blogs) Become a Certified Professional
AWS Global Infrastructure

Programming & Frameworks

Topics Covered
  • C Programming and Data Structures (16 Blogs)
  • Comprehensive Java Course (4 Blogs)
  • Java/J2EE and SOA (346 Blogs)
  • Spring Framework (8 Blogs)
SEE MORE

Arraylength in JavaScript : Everything you Need to Know

Last updated on Jun 14,2023 468 Views


Variable are used to store values of the data type that is being defined by the user but it can store only one value. Arrays are a method used for storing many values in a single variable. In this article, we will discuss JavaScript Arrays and what is the Arraylength in JavaScript in the following sequence:

 

INTRODUCTION

Arrays are used to store several values of the same type in a single variable. In technical terms is a type of linear data structures. In simpler words, data is stored in a certain order that is one after the another. An array is a contiguous allocation of memory for data values of the same datatype.

Array length - Arraylength in javascript - edureka

 

ARRAY INDEXING

Array indexing technically represents the position of an element. An element is a data value that is being stored in the array. Array indexing starts from 0 ,i.e. the first element’s position number is denoted by 0.

Array Index - Arraylength in JavaScript - edureka

Arr[0]=45.
Then in the array Arr at 0th position data element 45 is present.

Discover the power of Flutter and learn how to leverage its features in a Flutter Development Course.

Arraylength In JavaScript -WHAT IS IT?

Array.length is an instance of type Array is of the object property length. The property length of Array returns the number of elements in the array. It can also help to update the length of the Array( that is increasing or decreasing the number of elements. The value of the property length is an positive integer ranging from less than 2 to 32nd power of 2 (232). For more check out this full stack developer course now.

 

Syntax:


array.length

Code:


<html>
<head>
<title>Array Length in JavaScript</title>
</head>
<body>
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%20%3D%20%22text%2Fjavascript%22%3E%0Avar%20arr%20%3D%20new%20Array(%2010%2C%2020%2C%2030%2C%2040%2C%2050%20)%3B%0Adocument.write(%22arr.length%20is%20%3A%20%22%20%2B%20arr.length)%3B%0A%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
</body>
</html>

Output:

arr.length is : 5

 

PROPERTY ATTRIBUTES RELATED TO Array.length

 

PropertyValue
WritableYES
ConfigurableNO
EnumerableNO
    • WRITABLE: If this attribute set to false, the value of the property remains unchanged.
    • CONFIGURABLE: If this attribute set to false, then any attempts to delete the property or change its attributes will fail.
    • ENUMERABLE: If this attribute set to true, the property will be iterated over during for loops.

     

    DIFFERENCE BETWEEN LENGTH AND INDEXING

    • Indexing is the position number of the element in an array while length is the number of elements present in any array.
    • Indexing starts from 0 while length starts from 1.
    • Indexing range starts from 0 to n-1 and length ranges from 1 to n.

     

    With this, we have come to the end of our article. I hope you understood what is Arraylength in JavaScript and how it works.

    Now that you know about Arraylength in JavaScript, check out the Web Development Certification Training by Edureka. Web Development Certification Training will help you learn how to create impressive websites using HTML5, CSS3, Twitter Bootstrap 3, jQuery and Google APIs and deploy it to Amazon Simple Storage Service(S3). 

    If you want to get trained in React and wish to develop interesting UI’s on your own, then check out the React Certification Course by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe.

    Got a question for us? Please mention it in the comments section of “Arraylength in JavaScript” and we will get back to you.

    Upcoming Batches For Java Course Online
    Course NameDateDetails
    Java Course Online

    Class Starts on 3rd August,2024

    3rd August

    SAT&SUN (Weekend Batch)
    View Details
    Java Course Online

    Class Starts on 28th September,2024

    28th September

    SAT&SUN (Weekend Batch)
    View Details
    Comments
    0 Comments

    Join the discussion

    Browse Categories

    webinar REGISTER FOR FREE WEBINAR
    REGISTER NOW
    webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP

    Subscribe to our Newsletter, and get personalized recommendations.

    image not found!
    image not found!

    Arraylength in JavaScript : Everything you Need to Know

    edureka.co