@@ -748,29 +748,29 @@ Consideramos implementar eles a partir das seguintes regras:
748
748
` ` ` js
749
749
Function .prototype .myCall = function (context ) {
750
750
var context = context || window
751
- // Add an property to the `context`
751
+ // Adiciona uma propriedade ao `context`
752
752
// getValue.call(a, 'yck', '24') => a.fn = getValue
753
753
context .fn = this
754
- // take out the rest parameters of `context`
754
+ // pega os parâmentros do `context`
755
755
var args = [... arguments ].slice (1 )
756
756
// getValue.call(a, 'yck', '24') => a.fn('yck', '24')
757
757
var result = context .fn (... args)
758
- // delete fn
758
+ // deleta fn
759
759
delete context .fn
760
760
return result
761
761
}
762
762
` ` `
763
763
764
- The above is the main idea of simulating ` call` , and the implementation of ` apply` is similar.
764
+ O exemplo acima é a idéia central da simulação do ` call` , e a implementação do ` apply` é similar.
765
765
766
766
` ` ` js
767
767
Function .prototype .myApply = function (context ) {
768
768
var context = context || window
769
769
context .fn = this
770
770
771
771
var result
772
- // There's a need to determine whether to store the second parameter
773
- // If the second parameter exists, spread it
772
+ // Existe a necessidade de determinar se guarda o segundo parâmentro
773
+ // Se o segundo parâmetro existir, espalhe ele
774
774
if (arguments [1 ]) {
775
775
result = context .fn (... arguments [1 ])
776
776
} else {
@@ -782,9 +782,9 @@ Function.prototype.myApply = function (context) {
782
782
}
783
783
` ` `
784
784
785
- The role of ` bind` is the same as the other two, except that it returns a function. And we can implement currying with ` bind`
785
+ A regra do ` bind` é a mesma das outras duas, exceto que ela retorna uma função. E nós podemos implementar currying com o ` bind`
786
786
787
- let’s simulate ` bind` :
787
+ vamos simular o ` bind` :
788
788
789
789
` ` ` js
790
790
Function .prototype .myBind = function (context ) {
@@ -793,9 +793,9 @@ Function.prototype.myBind = function (context) {
793
793
}
794
794
var _this = this
795
795
var args = [... arguments ].slice (1 )
796
- // return a function
796
+ // retorna uma função
797
797
return function F () {
798
- // we can use `new F()` because it returns a function, so we need to determine
798
+ // Nós podemos usar `new F()` porque ele retorna uma função, então precisamos determinar
799
799
if (this instanceof F ) {
800
800
return new _this (... args, ... arguments )
801
801
}
0 commit comments