Olga1108 4 年之前
父節點
當前提交
931ee25a0a
共有 1 個文件被更改,包括 20 次插入18 次删除
  1. 20 18
      js04/index.js

+ 20 - 18
js04/index.js

@@ -71,24 +71,26 @@ food.addProperty('fruit', 'apricot')
 console.log(food)
 // hw5
 // Обязательное
-// function sampleFunc () {
-//     console.log(`${arguments.callee.name}: ${arguments[0]} | ${arguments[1]}`)
-// }
-// function modificator (func) {
-
-// }
-// testFunc = modificator(sampleFunc)
-// testFunc()
-// // Дополнительно
-// function sampleFunk () {
-//     console.info (`Symbols in my code: ${arguments.calle + 0}`)
-// }
-// function modificator (func) {
-//     var amountSymbols = String(func).length
-//     console.info (`Symbols in my code: ${amountSymbols}`)
-// }
-// modificator( sampleFunc )
-// sampleFunc()
+ function sampleFunc_ () {
+     console.log(`${arguments.callee.name}: ${arguments[0]} | ${arguments[1]}`)
+ }
+ function modificator_ (func) {
+    return func.bind(null, 'test', 'sample')
+ }
+testFunc = modificator_(sampleFunc_)
+testFunc() 
+ // Дополнительно
+ function sampleFunc () {
+     console.info (`Symbols in my code: ${arguments.callee + 0}`)
+ }
+ function modificator (func) {
+     let amountSymbols = func.toString().length;
+     func.valueOf = function() {
+     return amountSymbols;
+     }
+ }
+ modificator( sampleFunc )
+ sampleFunc()
  // Дополнительно
  function testArguments () {
      function generateError (numArgs) {