Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Errore JSLint for...in

  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2014
    residenza
    Voltati
    Messaggi
    913

    Errore JSLint for...in

    JSLint mi segnala un errore "inaspettato":

    The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype. for (y in params.attr) {


    Il codice sembra funzionare lo stesso, ma vi chiedo per non rischiare di avere qualche problema.
    Non basta fare così?
    codice:
    for (y in params.attr) { // Linea incriminata
    	if (y !== "prototype") { // Controllo che non sia il prototype
    		// ...
    		// ...
    		// ...
    	}
    }
    No

  2. #2
    Quote Originariamente inviata da tampertools Visualizza il messaggio
    JSLint mi segnala un errore "inaspettato":

    The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype. for (y in params.attr) {


    Il codice sembra funzionare lo stesso, ma vi chiedo per non rischiare di avere qualche problema.
    Non basta fare così?
    codice:
    for (y in params.attr) { // Linea incriminata
        if (y !== "prototype") { // Controllo che non sia il prototype
            // ...
            // ...
            // ...
        }
    }
    guardati questa discussione: http://stackoverflow.com/questions/1...an-if-statemen
    max

    Silence is better than bullshit.
    @mmarcon
    jHERE, Maps made easy

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.