Here the logic runs JS?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
6 views
All good, here is the code and a couple of questions on it.
Who would not find difficult to answer, thank you!)

var team = { 13: 'Mickle', 10: 'Joe', 11: 'Stacy' } var player = 10; var question = team[player]; console.log(question);


actually a question: whether correctly I understand how JS works here. When we pointed out 'player' in brackets we are told JS that now it is necessary to look up the value in object with a similar value (10)?
Or is the logic slightly different? Please answer as accessible language)
by | 6 views

1 Answer

0 like 0 dislike
Yes that's right. So you're just trying to connect to a kind of value object.
The brackets give you just the advantage that they allow to use variables. With the dot, you wouldn't let go.

Read:
1 - https://medium.com/@prufrock123/js-dot-notation-vs...
2 - https://codeburst.io/javascript-quickie-dot-notati...
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
4 answers
asked Aug 3, 2019 by anton_trofimov95
110,608 questions
257,186 answers
0 comments
35,648 users