
// makeProfileTimerWrapp()
function makeProfileTimerWrapp() {

   function makeProfileTimer() {
      return function () {
         return performance.now()
      } 
   }
   let timer = makeProfileTimer()
   alert('Замеряем время работы этого alert')
   alert(timer())
}

// makeSaverWrapp()
function makeSaverWrapp() {

   function makeSaver(func) {
      let storage = null
      return function () {
         if (storage === null) {
            storage = func()
            return storage
         } else {
            return storage
         }
      }    
   } 

   let saver = makeSaver(Math.random)
   let value1 = saver()
   let value2 = saver()
   console.log(value1) 
   console.log(value2)
   console.log(value1 === value2) 

   let saver2 = makeSaver(() => console.log('saved function called') || [null, undefined, false, '', 0, Math.random()][Math.ceil(Math.random()*6)])
   let value3 = saver2()
   let value4 = saver2()
   console.log(value3 === value4) 
}

// finalCountdownWrapp()
function finalCountdownWrapp() {

   let i = 0;
   (function loop() {
      setTimeout(function () {
          console.log(++i)
          loop()
      }, 1000)
   })()
}

myBindWrapp()
function myBindWrapp() {

   function myBind(func, funcThis, array) {
      let params = array
      return function () {
         
      } 
   }

   let pow5 = myBind(Math.pow, Math, [undefined, 5])
   let cube = myBind(Math.pow, Math, [undefined, 3])
   pow5(2)
   cube(3) 
   console.log(pow5(2))
   console.log(cube(3))

   let chessMin = myBind(Math.min, Math, [undefined, 4, undefined, 5,undefined, 8,undefined, 9])
   chessMin(-1,-5,3,15) 
   console.log(chessMin(-1,-5,3,15))

   // let zeroPrompt = myBind(prompt, window, [undefined, "0"])
   // let someNumber = zeroPrompt("Введите число")  

   // myBind((...params) => params.join(''), null, [undefined, 'b', undefined, undefined, 'e', 'f'])('a','c','d') === 'abcdef'
}



