How to push additional fields to a javascript array from an oData result

How to push additional fields to a javascript array from an oData result

I have a ramdom array in javascript

I have a ramdom array in javascript

var dataModel = [];

I've queried an oData url and I want to fill the result in my dataModel [] array. And, for each item I want to add additional fields

odataMod.read(
        "/",
        null, [],
        true,
        function (oData, oResponse) {
            var data = oData.results;

        data.forEach(function (item) {
            //Add the object 
            dataModel.push(item);
            //I want to add additional fields to every object in data 
            dataModel.push(item.ObjectType = "Chevron");
            dataModel.push(item.HierarchyNodeLevel = 0);
            dataModel.push(item.IsCriticalPath = false);
            dataModel.push(item.IsProjectMilestone = false);
            dataModel.push(item.DrillDownState = "expanded");
            dataModel.push(item.Magnitude = 5);

...

Note : the ObjectType , DrillDownState , Magnitude (etc...) are the fields that I want to add with their values Chevron, 0, false (etc...)

Below is a screenshot of the current result :

But I want to add the additional properties inside each item and not outside , what I am doing wrong? In other word, I want the additional fields to be inside the metadata

Below is a sc of where I would like to add the items :


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Clone an Array in JavaScript?

In this JavaScript tutorial, you'll learn how to clone an array in JavaScript. Because arrays in JS are reference values, so when you try to copy it using the = it will only copy the reference to the original array and not the value of the array.

JavaScript Array.flatMap()

JavaScript Array.flatMap(): Use flatMap to map over an array and flatten the result array in one go! Now lets up the game and introduce "flatMap". It combines the steps of first mapping over the array with `map()` & then calling `flat()`. Instead of calling 2 methods, just use `flatMap()` 👍