javascript pass

前端 未结 1 501
情歌与酒
情歌与酒 2021-02-11 15:06

Is there something along the lines of python \'pass\' in javascript?

I want to do the javascript equivalent of:

try:
  # Something that throws exception
         


        
相关标签:
1条回答
  • 2021-02-11 15:58

    pass is a no-op in Python. You need it for empty blocks because

    try:
        # Something that throws exception
    catch:
    
    # continue other stuff
    

    is a syntax error. In JavaScript you can just use an empty catch block.

    try {
        // Something that throws exception
    }
    catch (e) {}
    
    0 讨论(0)
提交回复
热议问题