create 3 onjects in javascript

There are multiple ways to create objects in JavaScript. Here's one way of doing it using object literal syntax:

index.tsx
// Creating an object using object literal syntax
const myObj = {
  name: 'John',
  age: 30,
  email: 'john@example.com'
};

// Accessing object properties
console.log(myObj.name); // Output: John
console.log(myObj.age); // Output: 30
console.log(myObj.email); // Output: john@example.com
289 chars
12 lines

Another way to create objects is by using the Object.create() method. Here's an example:

index.tsx
// Creating an object using Object.create() method
const person =  Object.create({}, {
  name: { value: 'John' },
  age: { value: 30 },
  email: { value: 'john@example.com' }
});

// Accessing object properties
console.log(person.name); // Output: John
console.log(person.age); // Output: 30
console.log(person.email); // Output: john@example.com
347 chars
12 lines

In the above example, we pass an empty object ({}) as the first argument to the Object.create() method, and define the object's properties in the second argument using a key-value pair. Please note that the Object.create() method is not supported in Internet Explorer 8 and below.

I hope this helps!

gistlibby LogSnag