Skip to content

Instantly share code, notes, and snippets.

@jamc92
Created March 15, 2015 19:43
Show Gist options
  • Save jamc92/d1a2ad01261919286518 to your computer and use it in GitHub Desktop.
Save jamc92/d1a2ad01261919286518 to your computer and use it in GitHub Desktop.
JS - OOP
<!DOCTYPE html>
<html>
<head>
<title>Oriented Object Programming</title>
<script type="text/javascript">
//Creating an objetc
objeto = new Object();
//Creating an object's property
objeto.info = "Esta es a info de la propiedad";
//Setting a funcion
function miFunction() {
//Calling the info's content
alert(this.info);
}
//Assigning a function to an object.property
objeto.showInfo = miFunction;
</script>
</head>
<body>
<!--Calling an object function from a button-->
<button onclick="objeto.showInfo()">Info</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment