当前位置:网站首页>Number() VS parseInt()
Number() VS parseInt()
2022-07-26 21:26:00 【Ziwei front end】
both Number() and parseInt() Usually used to convert strings to numbers .
differences
Number()Conversion type , and parseInt Parse the entered value .
// Parsing
parseInt('32px'); // 32
parseInt('5e1'); // 5
// Convert type
Number('32px'); // NaN
Number('5e1'); // 50- As you can see ,
parseIntWill resolve to the first non numeric character . On the other hand ,NumberWill try to convert the entire string . parseIntTake two parameters . The second parameter is used to represent the cardinality .
parseInt('0101'); // 101
parseInt('0101', 10); // 101
parseInt('0101', 2); // 5
Number('0101'); // 101 When we pass special values , They will return different results , for example undefinedor null:
边栏推荐
- MySQL -count: the difference between count (1), count (*), and count (column name)
- [HCIA security] user authentication
- 一些意想不到的bug记录
- 通过单击表头对表进行排序
- Is it reliable, reliable and safe to open an account with a low commission for funds in Galaxy Securities
- LiveDatade的基本使用
- [hcie security] dual computer hot standby - primary and standby backup
- ROS2获取当前系统时间的方法
- Multivariable time series prediction using LSTM -- problem summary
- QT Foundation Day 1 (1) QT, GUI (graphical user interface) development
猜你喜欢

2022-7-26 第七组 抽象和接口

Pointpillars: fast encoders for object detection from point clouds reading notes

除了「加机器」,其实你的微服务还能这样优化

【MySQL系列】-索引知多少

今天公司碰到一个阿里p8,算是真正见识到了基础的天花板

Summary of 4 years of software testing experience and interviews with more than 20 companies after job hopping

一些意想不到的bug记录

Flutter性能优化实践 —— UI篇

Error in render: “TypeError: data.slice is not a function“

Sign up now: July 29 recommendation system summit 2022
随机推荐
Line detection based on Hough transform (matlab)
Redis hash和string的区别
6种方法帮你搞定SimpleDateFormat类不是线程安全的问题
Retrieve the parameters in this method in idea for our use -- 1. Class diagram. 2. Double click shift
word-break: break-all VS word-wrap: break-word
idea中检索此方法中有哪些参数以便我们使用——1.类图。2.双击shift
CONDA reports an error: json.decoder.jsondecodeerror:
测试用例千万不能随便,记录由一个测试用例异常引起的思考
After chatting with byte programmers with a monthly salary of 3W, I realized that I had been doing chores
Introduction of JDBC
2022-7-26 the seventh group of abstractions and interfaces
idea中debug时如何进入指定的用户方法体中?
JVM学习----内存结构----程序计数器&虚拟机栈&本地方法栈&堆&方法区
HTTP cache browser cache that rabbits can understand
How to enter the specified user method body when debugging in idea?
滤波及失真
JDBC connection
25张炫酷交互图表,一文入门Plotly
【HCIE安全】双机热备-主备备份
Custom annotation (I)