본문 바로가기

Develop/Web

ejs에서 변수가 undefined인지 검사하기

ejs에서 변수가 정의되어 있는지 확인하는 방법은 typeof를 사용하는 것이다.

if (typeof variable_here == 'undefined')


아래의 방법을 사용하면 정의되지 않은 변수라고 에러를 낼 것이다.

if (variable_here)