Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Parolina in nel codice js

    Sto ragionando su un codice non commentato del mio libro che trovo anche a questa pagina:

    http://compatibility.shwups-cms.ch/en/polyfills/?&id=61

    non riesco a capire il significato di questa riga:

    codice:
    if (i in t && fun.call(thisp, t[i], i, t)) {
    e neppure questo pezzo:

    codice:
    = function(fun /*, thisp */) {
    qui c'è il listato completo:

    codice:
    if (! Array.prototype.some) {
        Array.prototype.some = function(fun /*, thisp */) {
            "use strict";
    
            if (this === void 0 || this === null) {
                throw new TypeError();
            }
    
            var t = Object(this);
            var len = t.length >>> 0;
            if (typeof fun !== "function") {
                throw new TypeError();
            }
    
            var thisp = arguments[1];
            for (var i = 0; i < len; i++) {
                if (i in t && fun.call(thisp, t[i], i, t)) {
                    return true;
                }
            }
    
            return false;
        };
    }
    Più pratica in futuro...

  2. #2
    Utente di HTML.it L'avatar di m4rko80
    Registrato dal
    Aug 2008
    residenza
    Milano
    Messaggi
    2,655
    Ciao, IN lo puoi capire da qui.
    Il fatto che fun() sia una funzione è scritto in questo modo piuttosto che
    codice:
    function fun(){...}
    perchè viene creato Array.prototype.some che sarà poi richiamabile per comodità con some(PARAMETRI); Il /*this*/ è semplicemente del codice commentato

  3. #3
    thanks
    Più pratica in futuro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.