ho scritto sto codice:
ma parchè mi vede tutti gli attributi e i metodi dell'oggetto istanziato come string? lo scirpt scrive:codice:<script type="text/javascript"> // ecco la funzione costruttore function Anagrafica(nome, cognome, civico){ this.nome = nome; this.cognome = cognome; this.civico = civico; this.name_surname = function(){ return this.nome + " - " + this.cognome; } } // istanzio l'oggetto var fab = new Anagrafica("fabs", "surny", "48") // ed elenco le proprietà con for in // MIND: "prop" è una variabile creata a run time e ogni altro nome per questa variabile avrebbe funzionato ugualmente for (prop in fab){ document.write(prop + "->" + typeof(prop) + " "); } </script>
nome->string
cognome->string
civico->string
name_surname->string
metre io mi aspettavo
nome->string
cognome->string
civico->number
name_surname->Object

Rispondi quotando
