How to check the validity of variables in ejs template?

  node.js, question

Well, when using the ejs template
Many times, it is necessary to verify the validity of variables, including the length of arrays, etc.
So here comes the question
Some variables I didn’t pass in with render
How can I check it out?
Tried if(var)
typeof(var) ! == ‘undefined’
They all report mistakes.

Cannot read property 'name' of undefined

Do you have any good ideas?
Now it is necessary to pass an empty past, but I don’t need this empty past. I have to pass a lot of parameters in render every time ~

if (typeof(var) == ‘undefined’)

This will not make a mistake. . This is what I use here.
Var not is defined, can also be detected, not wrong.