File: UsingOOP.html

Recommend this page to a friend!
  Classes of Renato Menezes Portugal   Using OOP in JavaScript   UsingOOP.html   Download  
File: UsingOOP.html
Role: Example script
Content type: text/plain
Description: Example File and Documentation.
Class: Using OOP in JavaScript
Use private and public functions and variables
Author: By
Last change:
Date: 10 years ago
Size: 1,711 bytes
 

Contents

Class file image Download
<!DOCTYPE html> <html> <head> <link rel='stylesheet' href='style.css'/> <script src='script.js'></script> </head> <body> <script> //Instantiate the Class var varClass = new clsMyClasse(); document.write("--- Call the Public Attribute"); document.write("<br>"); document.write(varClass.atrAtributoPublico); document.write("<br>"); document.write("--- Call the Public Method (Returns the Private Attribute through the Private Method)"); document.write("<br>"); document.write(varClass.mtdMetodoPublico()); document.write("<br><br>"); //Instantiate the Method inside Class document.write("<br>"); var varJohn = new varClass.mtdPerson("John", "Smith", 30); document.write("--- Call the Public Attribute instantiated in Public Method"); document.write("<br>"); document.write(varJohn.atrFirstName); document.write("<br>"); document.write("--- Call the Public Attribute instantiated in Public Method"); document.write("<br>"); document.write(varJohn.atrLastName); document.write("<br>"); document.write("--- Call the Public Attribute instantiated in Public Method"); document.write("<br>"); document.write(varJohn.atrAge); document.write("<br><br>"); document.write("--- Accesses the Method inside another Method instantiated "); document.write("(Receives the value returned by the Method)"); document.write("<br>"); var varMtdmyBalance = varJohn.mtdGetBalance(); document.write(varMtdmyBalance); document.write("<br>"); </script> </body> </html>