1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- // makeProfileTimer
- {
- function makeProfileTimer() {
- let t0 = performance.now();
- return function tn() {
- let t1 = performance.now();
- return (t1 - t0) * 1000 + 'microseconds';
- };
- }
- let timer = makeProfileTimer();
- alert("Замеряем время работы этого alert");
- alert(timer());
- }
- // makeSaver
- {
- }
- // Final Countdown
- {
- let seconds = 5;
- function timer() {
- console.log(seconds);
- const timeout = setTimeout(() => {
- timer();
- }, 1000);
- if (seconds > 0) {
- return (function () {
- return seconds--;
- })();
- }
- clearTimeout(timeout);
- if (seconds === 0) {
- console.log("поехали!");
- }
- }
- timer();
- }
- // myBind
- {
- }
|