当前位置:网站首页>JS how to judge when data contains integer and floating-point types. Floating-point decimals retain two digits after the decimal point
JS how to judge when data contains integer and floating-point types. Floating-point decimals retain two digits after the decimal point
2022-06-26 12:23:00 【Yotoai Mengtian】
Throw questions :
When writing code today , Find out ajax Traversal data The number of digits after the floating point decimal point is too long ( There are many after the decimal point 0), Use .toFixed(2) when , Although the two decimal places are left after the floating point , however Integer data More .00 ( One more point and two zeros ).
resolvent :
Just go through the data , Add judgement :
var html = '';
for(var i = 0; i < data.length;i++){
html +='<tr><td>' + data[i].data? (parseInt(data[i].data)!=data[i].data?data[i].data.toFixed(2):data[i].data):0 + '</td></tr>'
}
边栏推荐
- 证券账户一般需要在哪里开通 开户安全吗
- JMeter response time and TPS listener tutorial
- 【概率论】条件概率、贝叶斯公式、相关系数、中心极限定理、参数估计、假设检验
- Statistical genetics: Chapter 1, basic concepts of genome
- Rookie practical UML - activity diagram
- Oracle lock table query and unlocking method
- Mqtt disconnect and reconnect
- Jsonarray and jsonobject of fastjson [easy to understand]
- Lintcode 130 · 堆化
- AD - 将修改后的 PCB 封装更新到当前 PCB 中
猜你喜欢

MOS管基本原理,单片机重要知识点

国际美妆业巨头押注中国
![[probability theory] conditional probability, Bayesian formula, correlation coefficient, central limit theorem, parameter estimation, hypothesis test](/img/2f/f44381ea759f4c1c957a8f9434f0ee.png)
[probability theory] conditional probability, Bayesian formula, correlation coefficient, central limit theorem, parameter estimation, hypothesis test

dried food! Yiwen will show you SD card, TF card and SIM card!

How to prevent weight loss under Gao Bingfa?

leetcode 715. Range 模块 (hard)

Comparison of latest mobile phone processors in 2020 (with mobile phone CPU ladder diagram)

Loggie encoding and newline character test

Pre knowledge of hash table -- binary search tree

【Redis 系列】redis 学习十六,redis 字典(map) 及其核心编码结构
随机推荐
2022 edition of investment analysis and "fourteenth five year plan" development prospect forecast report of China's switchgear industry
PolarisMesh系列文章——概念系列(一)
我想知道同花顺是炒股的么?在线开户安全么?
Omnichannel membership - tmall membership 1: opening tutorial
HUST網絡攻防實踐|6_物聯網設備固件安全實驗|實驗二 基於 MPU 的物聯網設備攻擊緩解技術
Five trends of member management in 2022
AD - 将修改后的 PCB 封装更新到当前 PCB 中
11、 Box styles and user interface
Spark-day01- get started quickly
China Medical Grade hydrogel market supply and demand research and prospect analysis report 2022 Edition
Member system + enterprise wechat + applet to help the efficient transformation of private domain
SQL injection in Pikachu shooting range
HUST网络攻防实践|6_物联网设备固件安全实验|实验三 FreeRTOS-MPU 保护绕过
Comparison of latest mobile phone processors in 2020 (with mobile phone CPU ladder diagram)
[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]
MOS管基本原理,单片机重要知识点
Leetcode 78. 子集 and 90. 子集 II
Precautions for opening a securities account is it safe to open an account
fastjson的JSONArray和JSONObject[通俗易懂]
【概率论】条件概率、贝叶斯公式、相关系数、中心极限定理、参数估计、假设检验