javascript by example
javascript by example
javascript by example
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Capitolo 1<br />
function isDefined (name){<br />
}<br />
return (window[name]!=null);<br />
//Oppure return (name in window);<br />
//Esempio:<br />
var s = "";<br />
document.write(isDefined('variabileInesistente'));// false<br />
document.write(isDefined('s'));// true<br />
Linguaggio<br />
da usare quindi passando come argomento il nome del riferimento<br />
da testare (sotto forma di stringa).<br />
1.2 LAVORARE CON GLI OGGETTI<br />
1.2.1 Le funzioni<br />
15 Dichiarare una funzione<br />
Le funzioni in <strong>javascript</strong> sono un oggetto veramente multiforme,<br />
ciò si può vedere anche dai modi in cui si possono dichiarare:<br />
// come oggetto implicitamente creato (metodo più comune)<br />
function myFunc(name){<br />
}<br />
return "Hello " + name;<br />
// equivalente : assegnazione di una var<br />
var myFunc = function (name){<br />
}<br />
return "Hello " + name;<br />
// equivalente : assegnazione al contesto globale<br />
window.myFunc = function (name){<br />
}<br />
return "Hello " + name;<br />
I libri di ioPROGRAMMO/Javascript <strong>by</strong> Example 19<br />
JAVASCRIPT<br />
BY EXAMPLE