How to use .length in Javascript
By FoxLearn 12/18/2024 7:02:05 AM 52
In JavaScript, `.length` is a property that returns the number of items in an array or the number of characters in a string.
For example:
// For an array let fruits = ['apple', 'banana', 'cherry']; console.log(fruits.length); // Output: 3 // For a string let message = 'Hello, world!'; console.log(message.length); // Output: 13
In this examples, .length
helps determine how many elements are in an array or how many characters are in a string.
Categories
Popular Posts
Freedash bootstrap lite
11/13/2024
Dashboardkit Bootstrap
11/13/2024
Material Lite Admin Template
11/14/2024
Stisla Admin Dashboard Template
11/18/2024