I want to create this structure dynamically in Javascript:
var myCols = [
{data1: 'A', data2: '0', data3: 1},
{data1: 'B', data2: '1', data3: 1},
{data1: 'C', data2: '2', data3: 1}
];
How can I do this?
Thank you in Advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your question is very vague. There are infinitely many ways to generate that dynamically. How you do it depends on the data you start with and how and when you want to create it. For example you could generate exactly that above code dynamically on the server side after a DB query, or you could generate it with something like this loop, which would go own through more letters in data1 and more numbers (as strings) in data2 if you increase 3 to something less than or equal to 26.