1 / 10

JavaScript

JavaScript. Oggetti. Linguaggio a oggetti. JavaScript è Object Oriented Sono presenti oggetti predefiniti del linguaggio E’ possibile definire nuovi oggetti Esistono oggetti ospiti definiti non dal linguaggio ma dall’ambiente di esecuzione: il browser Rappresentati nel DOM.

geneva
Télécharger la présentation

JavaScript

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JavaScript Oggetti

  2. Linguaggio a oggetti • JavaScript è ObjectOriented • Sono presenti oggetti predefiniti del linguaggio • E’ possibile definire nuovi oggetti • Esistono oggetti ospiti definiti non dal linguaggio ma dall’ambiente di esecuzione: il browser • Rappresentati nel DOM Alice Pavarani

  3. Oggetti in JavaScript • Proprietà (dati) • Metodi (funzioni) • Accesso • dot-notation • oggetti come array associativi oggetto.proprietà; oggetto.metodo; oggetto[proprietà]; Alice Pavarani

  4. Oggetti predefiniti • Array • Boolean • Date • Function • Global • Math • Number • Object • Option • RegExp • String • Creare un oggetto • http://www.w3schools.com/js vararray = new Array(); varoggetto = newObject(); Alice Pavarani

  5. Datehttp://www.w3schools.com/jsref/jsref_obj_date.asp • Serve per memorizzare dati di tipo temporali Alice Pavarani

  6. Mathhttp://www.w3schools.com/jsref/jsref_obj_math.asp • Oggetto per costanti e funzioni matematiche Alice Pavarani

  7. Numberhttp://www.w3schools.com/jsref/jsref_obj_math.asp • Oggetto per i valori numerici primitivi Alice Pavarani

  8. Stringhttp://www.w3schools.com/jsref/jsref_obj_string.asp • Utilizzata per rappresentare e manipolare dati testuali Alice Pavarani

  9. Creare nuovi oggetti • Creare un nuovo costruttore di oggetti • Creare un nuovo oggetto • Creazione per definizione incrementale functionpersona(n, c) { this.nome = n; this.cognome = c; } varMario = new persona(“Mario”,”Rossi”); varMario = {}; Mario.nome = “Mario”; Mario.cognome = “Rossi”; Alice Pavarani

  10. Creare i metodi di un oggetto • Il metodo nel costruttore • Creazione per definizione incrementale functionpersona(n, c) { this.nome = n; this.cognome = c; this.visualizzaNomeCognome = function () { returnthis.nome + " " + this.cognome; } } persona.nomeCognome = function () { returnthis.nome + " " + this.cognome; } Alice Pavarani

More Related