Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära The `length` Property | Exploring Arrays
Introduction to JavaScript
course content

Kursinnehåll

Introduction to JavaScript

Introduction to JavaScript

1. Getting Started
3. Conditional Statements
4. Mastering Functions
5. Exploring Arrays
6. Discovering Loops

book
The `length` Property

The length property can be used to quickly get the amount of elements in an array:

12
let numbers = [5, 7, 9, 10, 15, 25, 30, 35]; console.log("There are", numbers.length, "numbers in the array.");
copy
Note
Definition

A property is a variable associated with an object. It represents an attribute or characteristic of that object. In this case, the length is a property of the array object, and it returns the number of elements in the array. You can access properties the same way you access methods: objectName.propertyName.

1. What does the length property of an array return?

2. What will be the output of the following code?

question mark

What does the length property of an array return?

Select the correct answer

question mark

What will be the output of the following code?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 5. Kapitel 8

Fråga AI

expand
ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

course content

Kursinnehåll

Introduction to JavaScript

Introduction to JavaScript

1. Getting Started
3. Conditional Statements
4. Mastering Functions
5. Exploring Arrays
6. Discovering Loops

book
The `length` Property

The length property can be used to quickly get the amount of elements in an array:

12
let numbers = [5, 7, 9, 10, 15, 25, 30, 35]; console.log("There are", numbers.length, "numbers in the array.");
copy
Note
Definition

A property is a variable associated with an object. It represents an attribute or characteristic of that object. In this case, the length is a property of the array object, and it returns the number of elements in the array. You can access properties the same way you access methods: objectName.propertyName.

1. What does the length property of an array return?

2. What will be the output of the following code?

question mark

What does the length property of an array return?

Select the correct answer

question mark

What will be the output of the following code?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 5. Kapitel 8
Vi beklagar att något gick fel. Vad hände?
some-alt