12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //makeProfileTimer
- function makeProfileTimer (a){
- let startTime, endTime;
- startTime = performance.now();
- a
- endTime = performance.now();
- let time = (endTime - startTime)
- alert(`${time}`);
- }
- //makeSaver
- function makeServer(ser){
- let rRun
- let save
- return function sever(){
- if(!rRun){
- save = ser;
- rRun=true;
- }
- return save
- }
- }
- let saifer = makeServer(Math.random())
- value1 = saifer();
- console.log("first numb "+value1)
- value2 = saifer();
- console.log("second numb "+value2)
- value1===value2
- console.log("result "+ (value1+value2))
- //myBind
- function myBind(metod,globalObject,tXt){
- function desk(){
- let argum = Object.assign(tXt,arguments);
- return metod.apply(globalObject,argum);
- }
- return desk;
- }
- let pow5 = myBind(Math.pow, Math, [undefined, 5]);
- console.log(pow5(2));
- let cube = myBind(Math.pow, Math, [undefined, 3]);
- console.log(cube(3));
- let zeroPrompt = myBind(prompt, window, [undefined, "0"]);
- let someNumber = zeroPrompt("Введите число");
- console.log("твой номер ---> "+someNumber);7
- //timer ciler
- function timeCiller (a){
- for (step = 0; step < 1; step++){
- console.log(a)
- let timerId = setInterval(() => console.log(--a), 1000);
- setTimeout(() => { clearInterval(timerId); console.log('run'); }, (a*1000))
- }78
- }
- timeCiller(prompt("введите число обратного отсчёта","5"))
|