Syntax error: Illegal return statement in JavaScript

后端 未结 6 1484
南方客
南方客 2021-02-04 23:25

I am getting a really weird JavaScript error when I run this code:



        
6条回答
  •  再見小時候
    2021-02-04 23:40

    in javascript return statement only used inside function block. if you try to use return statement inside independent if else block it trigger syntax error : Illegal return statement in JavaScript

    Here is my example code to avoid such error :

    
    

    Please check Jsfiddle example

提交回复
热议问题