Встроенная нулевая проверка javaScript

return num || 0;
Pleasant Pigeon