Page 222 - Web_Application_v2.0_C12_Fb
P. 222

// Deleting a property
                 delete car.model;

                 document.write("Car's model: " + car.model + "<br>");
                 </SCRIPT>
                 </BODY>

                 </HTML>
              Output:























              Manage Object Methods

              Some methods to manage objects are as follows:

                Adding a Method: To add a new method to an object, use dot (.) or bracket ([]) notation.
                 object.methodName = function() {

                 // method code here
                 };
                 // OR
                 object["methodName"] = function() {
                 // method code here
                 };
                Updating a Method: To update an existing method, reassign its value using dot or bracket notation.

                 object.methodName = function() {
                 // new method code here
                 };

                 // OR
                 object["methodName"] = function() {
                 // new method code here
                 };
                Deleting a Method: To delete a method from an object, use the delete keyword.

                 delete object.methodName;
                 // OR
                 delete object["methodName"];

                220   Touchpad Web Applications (Ver. 2.0)-XII
   217   218   219   220   221   222   223   224   225   226   227