Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do undefined or remove a javascript function?

Tags:

javascript

I defined a global Javascript function:

  function resizeDashBoardGridTable(gridID){
  var table = document.getElementById('treegrid_'+gridID);
        .....
  }

After this function was used a few times, I want to remove(or undefined) this function because the Procedure code should be called again. if somebody try to call this method we need do nothing.

I don't way change this function right now.

so re-defined this function may be one way:

  function resizeDashBoardGridTable(gridID){
      empty,do nothing
   }

Thanks. any better way?

like image 594
Jammy Avatar asked Jul 06 '11 14:07

Jammy


1 Answers

If the functions needs to be called 1 time you use an anonymous self invoking function like this:

(function test(){
    console.log('yay i'm anonymous');
})();

If you have to call the function multiple times you store it into a var and set it to null when you're done.

Note: You don't have to name an anonymous function like I named it test. You can also use it like this:

(function(){
    console.log('test');
})();

The reason I do name my anonymous functions is for extra readability.

like image 63
Skoempie Avatar answered Oct 27 '22 00:10

Skoempie