if ($("#dataTable").data('timer')) {
...
}
NOTE this only returns true
if the data attribute is not empty string or a "falsey" value e.g. 0
or false
.
If you want to check for the existence of the data attribute, even if empty, do this:
if (typeof $("#dataTable").data('timer') !== 'undefined') {
...
}