In JavaScript, we can use the typeof operator to check the data type of a variable. To check if a variable contains a number, we can use the following syntax:
if (typeof variable === 'number') { // The variable contains a number}
This method is reliable and straightforward. It is also performant, as it does not require any additional function calls or object creations.