script.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //makeProfileTimer
  2. function makeProfileTimer (a){
  3. let startTime, endTime;
  4. startTime = performance.now();
  5. a
  6. endTime = performance.now();
  7. let time = (endTime - startTime)
  8. alert(`${time}`);
  9. }
  10. //makeSaver
  11. function makeServer(ser){
  12. let rRun
  13. let save
  14. return function sever(){
  15. if(!rRun){
  16. save = ser;
  17. rRun=true;
  18. }
  19. return save
  20. }
  21. }
  22. let saifer = makeServer(Math.random())
  23. value1 = saifer();
  24. console.log("first numb "+value1)
  25. value2 = saifer();
  26. console.log("second numb "+value2)
  27. value1===value2
  28. console.log("result "+ (value1+value2))
  29. //myBind
  30. function myBind(metod,globalObject,tXt){
  31. function desk(){
  32. let argum = Object.assign(tXt,arguments);
  33. return metod.apply(globalObject,argum);
  34. }
  35. return desk;
  36. }
  37. let pow5 = myBind(Math.pow, Math, [undefined, 5]);
  38. console.log(pow5(2));
  39. let cube = myBind(Math.pow, Math, [undefined, 3]);
  40. console.log(cube(3));
  41. let zeroPrompt = myBind(prompt, window, [undefined, "0"]);
  42. let someNumber = zeroPrompt("Введите число");
  43. console.log("твой номер ---> "+someNumber);7
  44. //timer ciler
  45. function timeCiller (a){
  46. for (step = 0; step < 1; step++){
  47. console.log(a)
  48. let timerId = setInterval(() => console.log(--a), 1000);
  49. setTimeout(() => { clearInterval(timerId); console.log('run'); }, (a*1000))
  50. }78
  51. }
  52. timeCiller(prompt("введите число обратного отсчёта","5"))