본문 바로가기
JavaScript/script

javascript NaN. infinity

by 아이티.파머 2010. 3. 2.
반응형
isNaN(x) isNaN() checks its parameter "x" to see if it's the value "NaN" (not a number)-  an illegal number. The function returns true if "x" is NaN, and false if not. A common example of NaN is 0 divided by 0. This function is required to detect NaN, as using equality operators (== or ===) won't do.
isFinite(x) Determines whether a number is finite. Returns false if x is +infinity, -infinity, or NaN. JavaScript 1.3 statement.
eval(s) Evaluates the string ("s") and returns the results of the evaluation (if available). Eval() allows you to dynamically construct a JavaScript statement or expression.

Examples:

eval("8+3+1") //returns 12
eval("alert(Math.random())") //alerts Math.random()


 NaN  값이 없을때 혹은 숫자 이외것이..      isNaN[true, false반환]
 infinity  표한알수 없는값 (소수 이하 길이...)   isFinite[true, false반환]

* http://www.javascriptkit.com/jsref/globalfunctions.shtml

* http://www.java2s.com/Tutorial/JavaScript/0160__Global/GlobalInfinity.htm

반응형