Name / Value Pair

When it comes to JavaScript, Objects are very important, but before that, I would like to talk about Name / Value Pair.
It is quite simple and the term itself tells us what we are dealing with.
Namely, it is a pair of two elements Name and Value, in which the first element Name maps to one Value.
The Name can be defined more than once, but can only be assigned one Value in any given context. However, Value can be the next Name / Value Pair.

This is an example of an ordinary Name / Value Pair. Where Name - Car, Value - "Mercedes".


As I mentioned, objects in JavaScript are very important, but what are objects in JavaScrip really?
The answer is simple - they are a collection of Name / Value Pairs.
Some other programming languages may have a more complex Objects concept, but in JavaScript, Objects are just that - a collection of Name / Values Pairs.

Here, we see the Object, which we named LaLiga. It consists of 3 Name / Value Pairs.

  1. teams/38
  2. atletico/stadium object
  3. barcelona/stadium object

It is easy to continue this path and see that the stadium object is a further set of Name / Value Pairs. In our case:

  1. name/"name of the stadium"
  2. seats/"number of seats on the stadium

Of course, keep in mind that leaving blank lines of code is not a good code-writing practice. However, I wanted to specify the division of name/value pairs to make them more visible.

Next Post

I'm going to talk about Global Object.