Stephan K.
Stephan K.

Reputation: 15702

JavaScript data structure explanation

Given the following JavaScript data structure - how would you describe it?

BLA = {
  date : 12345678,
  layers : {
    bottom : "bottomLayer"
  },
  numbers : [5,4,2,2,4],
  start : function(){}
}

I would say the following about above data structure, do you agree?

It is an object literal called BLA. BLA is initializted with 4 object members. The first one is date which value is 12345678 and the second one is the member layers which recursively stores an literal itself: bottom:"bottomLayer". The third member is referenced as numbers which holds an array with 5 values. The last member is referenced as start and its respective value is an anomyous function.

Upvotes: 1

Views: 195

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270609

You're right on track, except for this part which reads a little awkwardly:

second one is the member “layers” which recursively stores an literal itself: 'bottom:”bottomLayer”'

Instead I would just describe it as an object literal itself:

second one is the member “layers” which is an object literal containing the string property: 'bottom' whose value is ”bottomLayer”

layers is not really doing anything recursive; that's not quite the appropriate term. But you clearly understand what the object is.

Upvotes: 3

Related Questions