javascript - How to combine object array values into 1 array? -


I have a data object that has an object containing an tags array, through a loop Would like to capture the object and each object tag and finally add the coalition, adds the value to 1 array, which is called selections when the loop is completed. At the moment I am unable to solve it, I have tried to push the tag into an array, then use the underscore_uayan method, and also that every loop attempts to include the array in 1 but with success No. Can anyone suggest solutions?

Object:

JS

  var selection = []; Var data = ([[role: "developer", tag: "developer", tag: ["javascript", "css", "html"]}, {roll: "creator", tag: "creator", tag: ["Project Management", "Pitching", "Billing"]}]]); For (var i = 0, len = data.length; i & lt; len; i ++) {selection.concat (data [i] .tags); } Console.log (Selection);    

You need to reassign selection And to concat that again Then use:

 for  (var i = 0, len = data.length; i & lt; len; i ++) {selection = selection.concat (data [i]. Tags); }    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -