Await new

await new is a syntax used in JavaScript to create a new object and wait for its constructor to complete before continuing execution.

Here's a breakdown of the syntax:

Here's an example of how you might use await new:

async function createNewObject() {
  const myObject = await new MyClass();
  console.log(myObject);
}

class MyClass {
  constructor() {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve({ foo: 'bar' });
      }, 2000);
    });
  }
}

In this example, the createNewObject function uses await new to create a new instance of the MyClass constructor. The constructor returns a promise that resolves after 2 seconds, and the await keyword pauses the execution of the createNewObject function until that promise is resolved. Once the promise is resolved, the myObject variable is assigned the value of the resolved promise, and the console.log statement is executed.

Note that await new is only available in async functions, and it's generally used when you need to create a new object and wait for its constructor to complete before continuing execution.