Get length of array

Output

3

Code examples


JavaScript

let array = [1, 2, 3];
console.log(array.length);

Perl

my @array = (1, 2, 3);
my $len = $#array+1;
print $len."\n";

PHP

<?php
$array = [1, 2, 3];
print count($array)."\n";

Python

array = [1, 2, 3]
print(str(len(array)))

Ruby

array = [1, 2, 3]
print(array.length.to_s + "\n")