Exceptions thrown in asynchronous javascript not caught

前端 未结 3 2628
一整个雨季
一整个雨季 2021-02-20 17:46

Basically, why isn\'t this exception caught?

var http = require(\'http\'),
    options = {
      host: \'www.crash-boom-bang-please.com\',
      port: 80,
               


        
3条回答
  •  旧巷少年郎
    2021-02-20 18:35

    Javascript doesn't have just function scope, try-catch also is block scoped. That is the reason.

提交回复
热议问题