The This keyword is used to bind methods and properties to an instance of an object
<script type= "Text/javascript" >/*Check the constructor of the bank account object*/ functionChecking (amount) { This. balance = Amount;//Properties This. Deposit = Deposit;//Method This. withdraw = withdraw;//Method This. toString = tostring;//Method } functionDeposit (amount) { This. Balance + =amount; } functionWithdraw (amount) {if(Amount <= This. Balance) { This. Balance-=amount; } if(Amount > This. Balance) {Alert ("Insufficient funds"); } } functiontoString () {return"Balance:" + This. Balance; } varAccount =NewChecking (500); Account.deposit (1000); Alert (account.tostring ()); //balance:1500Account.withdraw (750); Alert (account.tostring ()); //Balance:Account.withdraw (800);//Show "Insufficient balance"Alert (account.tostring ());//Balance:</script>
The This keyword is used in the function