“Acara Timing JavaScript” Kode Jawaban

Javascipt Delay

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

console.log("Hello");
sleep(2000).then(() => { console.log("World!"); });
Witty Worm

Kode Pengaturan Waktu dalam JavaScript

var output = "";

// Start timing now
console.time("concatenation");

for (var i = 1; i <= 1e6; i++) {
  output += i;
}

// ... and stop.
console.timeEnd("concatenation");
Crazy Crossbill

Acara Timing JavaScript

<button onclick="setTimeout(myFunction, 3000)">Try it</button>

<script>
function myFunction() {
  alert('Hello');
}
</script>
naly moslih

OnClick Timer JavaScript

document.getElementById("gameStart").addEventListener("click", function(){
    var timeleft = 15;

    var downloadTimer = setInterval(function function1(){
    document.getElementById("countdown").innerHTML = timeleft + 
    " "+"seconds remaining";

    timeleft -= 1;
    if(timeleft <= 0){
        clearInterval(downloadTimer);
        document.getElementById("countdown").innerHTML = "Time is up!"
    }
    }, 1000);

    console.log(countdown);
});
Obedient Okapi

Jawaban yang mirip dengan “Acara Timing JavaScript”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya