Depending on what exactly you need:
-
is nullchecks whether the value isnull:{% if var is null %} {# do something #} {% endif %} -
is definedchecks whether the variable is defined:{% if var is not defined %} {# do something #} {% endif %}
Additionally the is sameas test, which does a type strict comparison of two values, might be of interest for checking values other than null (like false):
{% if var is sameas(false) %}
{# do something %}
{% endif %}