How do you wait for 5 seconds in JavaScript?

JavaScript
setTimeout(() => {  console.log("World!"); }, 2000);timeout(ms) { //pass a time in milliseconds to this function
    return new Promise(resolve => setTimeout(resolve, ms));
  }
Source

Also in JavaScript: