Javascript function overriding, Part 1
Disclaimer : All the javascript code, explaination and description in this blog series is particular to Internet Explorer only.
In Javascript, you can overide a function using the following method :
Method 1 |
<script language="javascript"> |
If you call foo(), it will display 'override foo is called'.
Recently, I discover another way of overriding function :
Method 2 |
<script language="javascript"> |
Both method will accomplish the same thing. However, they are semantically different.
Using method 1, what happen is the new code will over-write the existing code at the same memory address.
In method 2, the new code will be loaded into a different memory address and the function pointer foo will be changed to point to this new memory address.
What does this mean ? I will give an example and show you how to prove what I say in my next post.
Labels: web
3 Comments:
Nice article... love the examples
Link to part 2 is wrong. It has an additional 'r' within 'override':)
Thanks, this helped me out!
Post a Comment
<< Home