How to know if a value is empty
If I pass an empty array to jade, how can I know if it is empty?
JavaScript:
var data = [];
Jade:
if(data)
table ...
else
table ...
+3
Alvin
source
to share
2 answers
Use property length
:
if (data.length)
table ...
else
table ...
+11
alexpods
source
to share
you can use javascript to check the length of the array.
if (data.length==0){
// do something array is empty
}
here is the related answer from fooobar.com/questions/77088 / ...
+4
Naeem shaikh
source
to share