0

I have the below Javascript code:

const product = await productsRepo.getOne(req.params.id);
console.log(product);
console.log({product});

Output from first console.log.

{ title: 'hey12up', price: 1234, image: '', id: 'b6ff5da7' }

Output from second console.log:

{
  product: { title: 'hey12up', price: 1234, image: '', id: 'b6ff5da7' }
}

Though I understand that in the second output, product is a key and the value is an object (which are further key-value pairs), I dont understand how this conversion is done?

Just by enclosing the object name "product" inside braces, what is happening? Is there any technical term for this?

0 Answers0