[Javascript] Identify and Deal with NaN in JavaScript
2017-02-06 02:46
525 查看
Dealing with the special
NaNvalue can be tricky in JavaScript. It behaves like a number and not a number at the same time. This lesson explains how to identify it using the
isNaNfunction or the
Number.isNaNmethod.
Number.isNaN = Number.isNaN || function(x) {x !== x}
Number.isNaN(NaN) // true Number.isNaN("JS") // false Number.isNaN("") // false
相关文章推荐
- Four ways to deal with private members in JavaScript
- [CSSinJS] Convert Sass (SCSS) Styled Button to CSSinJS with JavaScript Templates and Variables
- Upload files in ASP.NET MVC with JavaScript and C#
- Javascript Module pattern template. Shows a class with a constructor and public/private methods/properties. Also shows compatibility with CommonJS(eg Node.JS) and AMD (eg requireJS) as well as in a br
- Creating Vista Gadgets: Using HTML, CSS and JavaScript with Examples in RSS, Ajax, ActiveX (COM) and
- How to deal with Whitespaces in scanf, gets(in C) and cin, getline(in C++) ?
- 【转】The Architecture Twitter Uses To Deal With 150M Active Users, 300K QPS, A 22 MB/S Firehose, And Send Tweets In Under 5 Second
- how to add Javascript and CSS in page layout with sharepoint 2013
- Building Applications with Force.com and VisualForce (DEV401) (二四):JavaScript in Visualforce
- Creating Web Applications in JavaScript with Express.js and ejs
- Object-orientation and inheritance in JavaScript: a comprehensive explanation
- Oracle 10.2.0.5 Dataguard creation and switchover/failover practise with RMAN in redhat 5.8 x64
- Working With Stored JavaScript in MongoDB
- You have a maze with obstacles and non-zero digits in it
- override deal with window closing in database application
- Read and write SD cards in a raw way with dd
- Create custom Task List and Forms in SharePoint 2010 with Visual Studio 2012
- "constantize" and "with_indifferent_access" method
- Javascript and AJAX with Yii(在yii 中使用 javascript 和ajax)
- UISearchController Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior