当前位置:网站首页>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>'
}
边栏推荐
- I want to know how the top ten securities firms open accounts? Is online account opening safe?
- Five problems and solutions of member operation
- How to calculate flops and params in deep learning
- 2022 edition of Beijing 5g industry investment planning and development prospect forecast analysis report
- Common problems and Thoughts on member operation management
- 4. N queen problem
- [solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]
- [graduation season · advanced technology Er] I remember the year after graduation
- Assembly language (7) operation instruction
- I want to know whether flush is a stock market? Is it safe to open a mobile account?
猜你喜欢

How to prevent weight loss under Gao Bingfa?

Spark-day01- get started quickly

Deep thinking from senior member managers
![[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

PHP uses laravel pay component to quickly access wechat jsapi payment (wechat official account payment)

2、 MySQL Foundation

"Pinduoduo and short video speed version", how can I roast!
![[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure](/img/d5/db1931596c26090092aaa065103dbb.png)
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure

Vscode solves the problem of Chinese garbled code
The loss of female scientists
随机推荐
Operation analysis and investment prospect research report of China's organic chemical raw material manufacturing industry 2022-2028
Mqtt disconnect and reconnect
Jsonarray and jsonobject of fastjson [easy to understand]
JMeter response time and TPS listener tutorial
I'd like to know what preferential activities are available for stock account opening? Is it safe to open an account online?
Hello! Forward proxy!
The loss of female scientists
International beauty industry giants bet on China
Common problems and Thoughts on member operation management
Re recognized! Know that Chuangyu has been selected as one of the first member units of the "business security promotion plan"
VMware virtual machine bridging mode can not access the campus network "suggestions collection"
Php+laravel5.7 use Alibaba oss+ Alibaba media to process and upload image / video files
Introduction to the strongest swarm cluster one click deployment + hydrogen bomb level container management tool
1、 MySQL introduction
我想知道,股票开户有哪些优惠活动?网上开户是否安全么?
File decryption in webgame development
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure
基于slate构建文档编辑器
Analysis report on China's photovoltaic inverter market prospect forecast and investment strategy recommendations in 2022
How can we reach members more effectively?