J
J
Jsman2016-06-08 18:24:10
JavaScript
Jsman, 2016-06-08 18:24:10

How to add a key/value to an object?

I will parse html . In html there are ul>li lists, I will add the key is the text ul , and the value is li , but I can’t figure out how to add them to the object.
What is the cat method that creates a new key and value?
// a piece of code does not parse html , but will give an understanding of how to do it . Thank you!

var obj = {};
var mass = ['Number1', 'Number2'];
  for(var i=0; mass.length; i++){

  }
// Как сделать такой объект
obj = {
  Number1 = '0';
  Number2 = '1'
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
polar-bear, 2016-06-08
@SeniorDmitry

obj[mass[i]] = i

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question