Is it possible to redefine a JavaScript function from within its own body. For example, could I do the following?
function never_called_again(args) {
// Do
Yes, it's possible, and it will not create a global function. I verified this in Internet Explorer 6, Firefox, Chrome, and Opera. Consider the following code:
Never called again
This will print "Hello World {function code}" the first time of the never_called_again and the second time it will print "hello {changed function code}" the second time.
But when it's being called on button's onclick, it will throw an error saying that the function is not defined, clearly indicating that the function was re-defined (and not created globally).