Question du test Javascript

Écrire un code Javascript qui affiche les indices d'un tableau.

Difficile

Qu'affichera le code suivant ?

var names = ['Lea', 'John', 'Rachel', 'Yehuda'];
(function() {
	for (name in names) {
		console.log(name);
	}
})();
Auteur: Jean-marie CléryStatut : PubliéeQuestion passée 1781 fois
Modifier
6
Évaluations de la communauté
developer avatar
Ludovic JIGAN
05/04/2024
Pour afficher les valeurs 'Lea', 'John', 'Rachel', 'Yehuda' il faut faire un for of
developer avatar
Afonso
06/04/2023
The code will display the index numbers of each element in the names array, as name represents the index and not the element itself. Therefore, the output will be: 0123