C
C
Cacatuidae2017-06-13 12:13:36
PHP
Cacatuidae, 2017-06-13 12:13:36

How to iterate a JS object in a source sequence?

Tell me how to display the JS object in the original order.
Example: https://jsfiddle.net/ecerev6a/ should output:

Not set ()
Yes (1)
No (0)

But it outputs:
No (0)
Yes (1)
Not set ()

How to make it output properly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2017-06-13
@Cacatuidae

No way, you need to use a data structure in which the order of the elements is guaranteed - an array.
For example:

var ar = [
  {value: '', text: 'Не задан'},
  {value: '1', text: 'Да'},
  {value: '0', text: 'Нет'}
];

http://learn.javascript.ru/object-for-in#in-what-the-p...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question