티스토리 뷰

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);
} 

 

'JavaScript' 카테고리의 다른 글

window in Javascript  (0) 2022.10.06
code refactoring 01  (0) 2022.10.05
Spread Operator  (0) 2020.12.26
Type Conversion in Javascript (number, string)  (0) 2020.09.15
Rest parameter  (0) 2020.08.26