A bug in Chrome developer tools

Source: Internet
Author: User
Tags chrome developer chrome developer tools

I entered the new company in October 12, and it's been half a month now.

This company is mainly mobile internet products, it is very suitable for me, I can see new things every day.

This May or June, when the code was easy to code, there was an inexplicable problem with chrome, and it was always refreshing. After this question, there was no reason to find out. This week in the new company code, and found that Chrome's developer tools There is a bug, and found the re-condition.

1 functionLoop () {2      for(varKeyinchUndefined) {//we add a break-point here,but it doesn ' t break on this line3         varItem=undefined[key];//It'll never get into this loop,cause of value undefined have no key-value pairs in it4 Console.log (item);5     }6 }7Loop ();//Add a break point Here,it works8Console.log ("Here we get the end");

The above code, if you try it in Chrome, and then hit the 2nd line, the results will not work at all.

Password Analysis:

    1. For (var key in undefined) {This loop does not go to the inside at all, because undefined does not exist any k-v.
    2. The 2nd line should be able to interrupt before runtime undefined whether there is k-v.

What is the actual situation? In Firefox, line 3rd doesn't go in, but it's harmless. In Chrome, the 2nd line should be interrupt, but not, skipped.

This particular line of Chrome brings a very worries fire to the code. We had a break in line 2nd, and we didn't stop at the expected time, and in general, we would think the reason was that the program was stopped by exception before. But looking at the console without any information about exception, instead, you can see that line 8th is being executed. The first time the failure of the program members, may be a time Zhang two monks can not touch the brain. To understand this problem, you have to spend your mind trying and experimenting, maybe 10 percent totem is half a day.

Strategy:

    1. There's a problem in Chrome, and in Firefox try to see if the table is consistent
    2. Add alert in front of the loop to see if the method has been entered

I can only think of these two points at a time, if anyone has a good experience, hope to teach.

A bug in Chrome developer tools

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.