Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //When you commonly declare an array variable in JS
- var questionsList=[];
- //And now you want to push an element into it using for loop
- for(var i=0; i<someVar.length; i++) {
- questionsList.push(someVar[i].question);
- }
- //If you would like to remove some index, then first take the index
- var index = wrapList.indexOf(0);
- wrapList.splice(index,1);
- //Above the second param basically tells to remove one element from the 0 index, if you give it 2, it will remove two elements, keep it 1
- //Now consider you wanted to declare a variable in JS with a key and a value, then you would have declared like this:
- var wrapList = [{label="", value=""}, {label="", value=""}];
- //However, above just can have two elements when you push some value into it
- wrapList[0].label = 'test';
- wrapList[0].value = 'testvalue';
- wrapList[1].label = 'test1';
- wrapList[1].value = 'test1value';
- //You can ofcourse try creating a map variable in JS dynamically, i am still to figure out that, but do hit me with comments on it, if you know
Add Comment
Please, Sign In to add comment