main.js 838 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // makeProfileTimer
  2. {
  3. function makeProfileTimer() {
  4. let t0 = performance.now();
  5. return function tn() {
  6. let t1 = performance.now();
  7. return (t1 - t0) * 1000 + 'microseconds';
  8. };
  9. }
  10. let timer = makeProfileTimer();
  11. alert("Замеряем время работы этого alert");
  12. alert(timer());
  13. }
  14. // makeSaver
  15. {
  16. }
  17. // Final Countdown
  18. {
  19. let seconds = 5;
  20. function timer() {
  21. console.log(seconds);
  22. const timeout = setTimeout(() => {
  23. timer();
  24. }, 1000);
  25. if (seconds > 0) {
  26. return (function () {
  27. return seconds--;
  28. })();
  29. }
  30. clearTimeout(timeout);
  31. if (seconds === 0) {
  32. console.log("поехали!");
  33. }
  34. }
  35. timer();
  36. }
  37. // myBind
  38. {
  39. }