1var object = {'Name'};
2var array = [ ]; // Create empty array
3
4// SIMPLE
5 array.push(object); // ADDS OBJECT TO ARRAY (AT THE END)
6 // or
7 array.unshift(object); // ADDS OBJECT TO ARRAY (AT THE START)
8
9// ADVANCED
10 array.splice(position, 0, object);
11 // ADDS OBJECT TO THE ARRAY (AT POSITION)
12
13 // Position values: 0=1st, 1=2nd, etc.
14 // The 0 says: "remove 0 objects at position"
1var select =[2,5,8];
2var filerdata=[];
3for (var i = 0; i < select.length; i++) {
4 filerdata.push(this.state.data.find((record) => record.id == select[i]));
5}
6//I have a data which is object,
7//find method return me the filter data which are objects
8//now with the push method I can make array of objects
1var nietos = [];
2var obj = {};
3obj["01"] = nieto.label;
4obj["02"] = nieto.value;
5nietos.push(obj);
6
1var studentList = ['Jason', 'Samantha', 'Alice', 'Joseph'];
2
3//Add a new student to the end of the student list
4studentList.push('Jacob');
5//list is updated to ['Jason', 'Samantha', 'Alice', 'Joseph', 'Jacob'];