|
@@ -60,4 +60,37 @@ var saver = makeSaver(Math.random)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ function myBind(funk, context) {
|
|
|
+
|
|
|
+ let arg = [].slice.call(arguments, 2);
|
|
|
+ arg = arg[0].filter(index => index != undefined)
|
|
|
+ return function () {
|
|
|
+ debugger
|
|
|
+ let newArg = [].slice.call(arguments);
|
|
|
+ return funk.apply(context, newArg.concat(arg))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var pow5 = myBind(Math.pow, Math, [undefined, 5])
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var cube = myBind(Math.pow, Math, [undefined, 3])
|
|
|
+
|
|
|
+ console.log(pow5(2))
|
|
|
+ console.log(cube(3))
|
|
|
+
|
|
|
+
|
|
|
+ var chessMin = myBind(Math.min, Math, [undefined, 4, undefined, 5,undefined, 8,undefined, 9])
|
|
|
+ console.log(chessMin(-1,-5,3,15))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var zeroPrompt = myBind(prompt, window, [undefined, "0"])
|
|
|
+
|
|
|
+ var someNumber = zeroPrompt("Введите число")
|