showing results for - "how to iimutable aray javascript"
Sean
07 Nov 2017
1const originalValue = [
2  { id: 'a11-a', createdAt: "2021-05-12T01:35:59.000Z" },
3  { id: 'a11-b', createdAt: "2021-05-12T01:35:48.000Z" },
4  { id: 'a11-c', createdAt: "2021-05-12T00:28:32.000Z" },
5  { id: 'b11-a', createdAt: "2021-05-12T00:27:43.000Z" },
6  { id: 'b11-b', createdAt: "2021-05-12T00:26:36.000Z" },
7  { id: 'b11-c', createdAt: "2021-05-12T00:24:01.000Z" }
8]
9
10const modifValue = []
11
12originalValue.forEach(val => {
13  const arrObject = Object.create(val)
14  arrObject.id = arrObject.id.replace(/-\w+/, '')
15  modifValue.push(arrObject)
16})
17
18console.log(originalValue)
19console.log(modifValue)