JS error mechanism

Source: Internet
Author: User
JS error mechanism: In JS if you encounter errors he will not be immediately thrown he will not find the current execution environment, see whether the current can be stopped, if not stop to go to the higher level of the environment to find (step-by-step search) has been found to handle the error environment. LET fn = () =>{alert (1)}let fn2 = () =>{alert (2)} var promise = new Promise (function (resolve,rejected) {//settimeout ( ) =>{fn ()//resolve () Rejected ("HelloWorld")//At this time reject does not trigger},1000);//timer will cause memory leakage, so to empty the timer})// This is a good decoupling method (to make it separate or less contact)//a Promise represents a separate program Promise.then (function () {return new Promise (function (succeful, Failed) {SetTimeout (() =>{fn2 ()},1000)})},function (e) {console.log (e);}). Then ()//The input chain syntax result is 1 hellowrold//js error mechanism: In JS if you encounter errors he will not immediately throw him will not//he will find the current execution environment, see if the current can be stopped, if not stop to go to the superior environment (search)// Always found in an environment where errors can be handled

JS error mechanism

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.