Unknown JavaScript syntax before for…in

前端 未结 3 1350
慢半拍i
慢半拍i 2020-12-12 00:32

I am reading a book about single-page applications and at some point there is this for...in loop:

KEYVAL:
for(key_name in arg_map){
    if(arg_map.hasOwnProp         


        
3条回答
  •  遥遥无期
    2020-12-12 01:12

    KEYVAL: is a label here which is used in your loop for iteration the operations. Look at the documentation

    It is similar to GOTO statements.

    What it does in your code is when this condition become true

    if(key_name.indexOf('_') === 0) continue KEYVAL;
    

    its go to the label KEYVAL: and run the loop again without executing the code below this line.

提交回复
热议问题