JavaScript

short circuit evaluation

seoca 2020. 12. 26. 23:51

 

1. This single line of short circuit evaluation is 

let value = options && options.value || '';

 

equal to this code

let value;
if(options){   
    value = options.value;
}
else
    value = '';

 

 

 

2.

stick > min && target.push(stick - min);

 

if(stick > min){
    target.push(stick - min);
}