-3
convert [{
"name":"abc"
},
{"name" : "xyz"
}]

to

(abc),(xyz)

Convert object of array to array to store mulitple records into mysql

1
  • 1
    Now would be a good time to read through How to Ask? You should be showing us what you attempted to solve this problem yourself and any research you have done. There are many many questions on this site alone about transforming arrays Commented Dec 18, 2016 at 21:14

1 Answer 1

2

You can use a map function like this:

map(function (v) {
  return v.name;
});

Snippet

var a = [{
  "name": "abc"
}, {
  "name": "xyz"
}];
a = a.map(function (v) {
  return v.name;
});
console.log(a);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.