JavaScript
Javascript OOP - Code reference
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="jsbox"></div>
<script type="text/javascript">
// Global namespace
// var MYAPP = MYAPP || {};
var MYAPP = {};
MYAPP.test = function(){
var someTxt = "MYAPP test function output";
return someTxt;
}
// Sub namespace (MYAPP.event)
// Object together with the method declarations
MYAPP.event = {
addListener: function(el, type, fn) {
// code stuff
},
removeListener: function(el, type, fn) {
// code stuff
},
getEvent: function(e) {
// code stuff
},
testEvent: function() {
var moreTxt = "More text";
return moreTxt;
}
// Can add another method and properties
};
document.getElementById("jsbox").innerHTML = MYAPP.test();
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="jsbox"></div>
<script type="text/javascript">
// Global namespace
// var MYAPP = MYAPP || {};
var MYAPP = {};
MYAPP.test = function(){
var someTxt = "MYAPP test function output";
return someTxt;
}
// Sub namespace (MYAPP.event)
// Object together with the method declarations
MYAPP.event = {
addListener: function(el, type, fn) {
// code stuff
},
removeListener: function(el, type, fn) {
// code stuff
},
getEvent: function(e) {
// code stuff
},
testEvent: function() {
var moreTxt = "More text";
return moreTxt;
}
// Can add another method and properties
};
document.getElementById("jsbox").innerHTML = MYAPP.test();
</script>
</body>
</html>