JSFiddle - React, Tailwind, and code Playground

by Rodwyn Moreno

JavaScript

const mainRows = [
{name: "SiteId", display: "Site ID", width: "120", datatype: "text"},
{name: "Name", display: "Contact Name", width: "70", datatype: "text"},
{name: "Address", display: "Address", width: "280", datatype: "text"},
{name: "City", display: "City", width: "100", datatype: "text"},
{name: "State", display: "State", width: "100", datatype: "text"},
{name: "Zip", display: "ZIP Code", width: "80", datatype: "text"},
{name: "CreatedBy", display: "Creator", width: "70", datatype: "text"}
];

const newArray = [];
mainRows.forEach(row => {
	const {width, datatype, ...newObj} = row;
newArray.push(newObj);
});

console.log(newArray);

/* var b = mainRows.map(item => {
return { width, datatype, ...newObj} = item
});

console.log('b: ', b); */

const c = [];
mainRows.forEach(row => {
	const {name, display} = row;
	c.push({name, display});
});

console.log('c: ',c)

const d = mainRows.map(row => {
	const {name, display:title } = row;
	return {name, title}
});

console.log('d: ', d)