Some basic concepts in Object oriented JavaScript’s are discussed below
<input type="button" id="btnCheck" onclick="GetData();" />
We have a button that calls a client side function GetData() on its click.
<script language="javascript" type="text/javascript">
function GetData() {
testBL.getTestData();
//calling function in testBLL.js
//with object testBL and function getTestData()
}
</script>
Now we will have to create testBLL.js
In this we can create the methods and expose those methods
Code in testBLL.js:
var testBL = new function () {
ObjectOreientedScripttest = function () {
//you can write your function code here
},
getTestDataByDate = function () {
//you can write your function code here
}
return {
testForObjectOreientedScript:ObjectOreientedScripttest ,
getTestData: getTestDataByDate
}
}
} ();
This return statement is mandatory to expose those methods.
For eg:
Inside the return statement we have the below statements
getTestData: getTestDataByDate
getTestDataByDate is the function we have created in the testBLL.js and second one getTestData is the name that we get when we are calling the method.
I.e. testBL.getTestData();
testBL is the variable name that we used for testBLL.js functions(refer first line testBLL.js)