Question du test Javascript

Quelle est la valeur de `obj.hello` après l'exécution de ces quelques lignes de code?

Difficile

Que vaut obj.hello après l'exécution de ces quelques lignes de code ?

var obj = { hello: 'Hello' }, hello = 'Hello';
obj[hello] += ',';
obj.hello += ' world';
obj['hello'] += '!';
Auteur: Jean-marie CléryStatut : PubliéeQuestion passée 1854 fois
Modifier
3
Évaluations de la communauté
developer avatar
Auteur anonyme
14/02/2022
outputs ' Helloworld!' in the console
developer avatar
Auteur anonyme
21/02/2022
Hello there. It seems to be an issue with the english translation. Thank you for the reporting. I fix it !
developer avatar
Auteur anonyme
10/03/2023
I tested the code here and it actually logs "Hello world!". The line `obj[hello] += ','` is useless tho.
developer avatar
Auteur anonyme
05/10/2023
I think it is the purpose of the test