Mode entretien. Minuteur de 5 min, sans indices ni autocomplétion
Object keys and indexes
FacileBasics5 min
What does this program print? Write the output: one line for each console log call, in the same order.
const answers = { true: 'yes', 1: 'no', 1.0: 'maybe' };
console.log(answers);
console.log(Object.keys(answers).length);
console.log(['123', 'yes'][0][1]);
console.log(['123', 'yes'][false]);- Think about what each key of the object becomes. JavaScript changes values to other types by itself (type coercion).
- In the last two lines, look at what each index picks.
- Type each line exactly as the console shows it. An object is printed like
{ a: 1 }, with spaces inside the braces, and a string inside an object has single quotes. A key that is a valid variable name has no quotes; any other key, for example one that starts with a digit, is printed in single quotes.
Posé chez Rostelecom · Source
Votre réponse
Chargement de l'éditeur...
Exécutez votre code pour voir ici les résultats des tests