Is there any way to delete a object from its method.
Let me explain a bit elaborately. I have a JS class called "Test" and I create a new instance of this class and assign it to a variable as below.
var Test = function()
{
}
Test.prototype =
{
printLog: function()
{
// Print some values
},
destroy: function()
{
//Here I want to delete **this** Test object.
}
}
var a = new Test();
Now I want to delete the newly created Test class object which is assigned in variable a by invoking a.destroy as below.
a.destroy();
console.log(a); //It should print null instead on object code.
After call the destroy() method, variable a value should be printed as null in console log.