get the value of 0/0 in javascript

In JavaScript, dividing zero by zero (0/0) results in a special value called NaN (Not a Number). NaN is a placeholder value indicating an undefined or unrepresentable value resulting from an operation.

You can get the value of NaN by dividing zero by zero or by calling the global NaN property:

console.log(0/0); // Output: NaN
console.log(NaN); // Output: NaN
66 chars
3 lines

It is important to note that NaN is not equal to any value, including itself. To check for NaN, you can use the built-in isNaN() function:

console.log(isNaN(0/0)); // Output: true
console.log(isNaN(NaN)); // Output: true
console.log(isNaN(5)); // Output: false
122 chars
4 lines

related categories

gistlibby LogSnag