Multiple catch in javascript

后端 未结 4 1010
清歌不尽
清歌不尽 2021-01-04 00:34

Is it possible to use multiple catch in JS(ES5 or ES6) like I describe below (it is only example):

try {
­­­­  // just an error
  throw 1; 
}
ca         


        
4条回答
  •  长情又很酷
    2021-01-04 01:34

    No. That does not exist in JavaScript or EcmaScript.

    You can accomplish the same thing with an if[...else if]...else inside of the catch.

    There are some non-standard implementations (and are not on any standard track) that do have it according to MDN.

提交回复
热议问题