JSFiddle - React, Tailwind, and code Playground

by David Simpson

JavaScript

// I have a rather frustrating error with the spread operator and javascript. Below are two scripts, the second does not "spread" the new id into the object - any idea what I am doing wrong?

const newCollections_ = {
  id: 'a19a760c-d68b-46b6-8ad2-d9744f4164cf',
  className: 'collections',
  createDate: '2021-01-20T13:39:59.967Z',
  friendlyId: null,
  createdByUser: 'PaulsUser_Id',
  includedByUser: [ 'PaulsUser_Id' ],
  parentId: null,
  parentClassName: null,
  childClassName: 'collection',
  childrenIds: [
    'a5388b09-2e54-49e9-83b7-750581cfda0b',
    'bdd7faaa-d7e8-40f5-ae68-62158beb6390',
    'c34abab2-98a7-44b1-b037-e4686e26ec04'
  ],
  title: null,
  notes: null,
  url: null,
  imageUrl: null,
  tags: [],
  comments: []
}

const ob1 = {
			name:'bob',
			occ:'laywer'
		}
const modob_1 = {
	...ob1,
	occ:'it'
}
console.log('modob1:', modob_1)
///   modob1: { name: 'bob', occ: 'it' }


const mockupwIds = {
  ...newCollections_,
    id:'xvvv',
};

console.log('mockupwIds zzz:', mockupwIds);
//	 mockupwIds zzz: {
//	id: 'a19a760c-d68b-46b6-8ad2-d9744f4164cf',

// 	should be 
//	id:'xvvv',