Different prototype methods may affect the debugging solution _ javascript skills

Source: Internet
Author: User
Different prototype methods may affect debugging solutions. I wrote an article last time to discuss the difference between the two implementations of JavaScript class-defined prototype methods ". After the study, we found that apart from the different methods of initialization, we did not find anything else in principle, that is, the same method is used. However, when we set breakpoints for the prototype method in VS. NET, the two definition methods differ greatly.

First look at the following code example: 1 ToolBar. prototype. Dispose = function ()
2 {
3 var elmt = this. GetElement ();***
4 elmt. onselectstart = '';
5 elmt. oncontentmenu = '';
6 elmt. clearAttributes ();
7 // todo
8}
An error occurs when my code runs here. The debugger VS. NET stops the code execution cursor at line 1 without dragging it. I think if I can drag it up, I can trace this. GetElement () method in step. Since it cannot be dragged, I just set a breakpoint in row 3rd. After setting the attach debugger, how can I not stop at line 3? In the debugger, the breakpoint is automatically set to the first line of code by VS. NET, and the entire ToolBar. prototype. Dispose method is highlight @_@. So I want to manually set the breakpoint to the 3rd line generation, but it cannot be successful. Once the breakpoint is set on line 1, it will automatically jump to line 2, but it can be set on lines after line 2, such as lines 4, 5, and 6. Here is a uugly solution, that is, a useless statement before the first line of code (simple var variable definition is not acceptable, at least var a = 1 ;), change the current 3rd rows to 4th rows. This bug is confusing.

Today we can solve this problem by changing ToolBar. prototype. Dispose = function () to function ToolBar. prototype. Dispose! Really strange !~ 1 function ToolBar. prototype. Dispose ()
2 {
3 var elmt = this. GetElement ();***
4 elmt. onselectstart = '';
5 elmt. oncontentmenu = '';
6 elmt. clearAttributes ();
7 // todo
8}
In the above method, you can set the breakpoint on the 3rd line at will. This problem also exists in VS. NET 2003 and VS. NET 2005 beta1. Who is free to take VS. NET 2005 beta2 and check if this problem persists.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.