Imagem de fundo

Javascript possibilita, através da prototipação de funções...

Javascript possibilita, através da prototipação de funções, a agregação de funções complementares às já implementadas pela linguagem. A implementação apresentada é um exemplo de expansão das funcionalidades do tipo de dados Array. Com base neste contexto, exerça o rastreio do código-fonte Javascript a seguir, considerando a chamada “[1,2,3,5,8].funcaoDeProva()”.


1. __Array.prototype.funcaoDeProva =

____function(callback) {

2.__ 'use strict';

3. __if (null === this | | 'undefined' === typeof this) {

4.__ throw new TypeError('Vetor nulo ou não definido'

____);

5. __}

6. __var t = Object(this), len = t.length >>> 0, k = len - 1,

____value;

7. __if (arguments.length >= 2) {

8. __value = arguments[1];

9. __} else {

10. __while (k >= 0 && !(k in t)) {

11. __k--;

12. __}

13. __if (k < 0) {

14. __throw new TypeError('Vetor ');

15. __}

16. __value = t[k]%2 === 0 ? t[k] : 0;

17. __k--;

18. __}

19. __for (; k >= 0; k--) {

20. __if (k in t) {

21. __value = value + (t[k]%2 === 0 ? t[k] : 0);

22. __}

23. __}

24. __return value;

25. __};


Assinale, a seguir, o valor retornado pela função.


A

2


B

10


C

13


D

19