当前位置:网站首页>JS foundation 5
JS foundation 5
2022-06-28 10:53:00 【Programmer community】
Math
Math Object as a storage mathematical formula , Information and Computing
attribute
| attribute | Method |
|---|---|
| Math.E | Base of natural logarithm e Value |
| Math.LN10 | With 10 The natural logarithm of the base |
| Math.LOG2E | With 2 Bottom e The logarithmic |
| Math.PI | π Value |
| Math.max() | Maximum |
| Math.min() | minimum value |
| Math.ceil() | Rounding up |
| Math.floor() | Rounding down |
| Math.round() | Round to the nearest whole |
| Math.fround() | Return to the nearest (32 position ) Floating point value |
| Math.random() | 0~1 Between random numbers |
| Math.abs() | Return the absolute value |
| Math.log() | Return to the natural logarithm |
notes :
Math.random() Random number but excluding 1
Built in Math The operation is faster than custom functions
Base number
Integers can be expressed in octal or hexadecimal literal
- Octal must be preceded by 0
var num=016
console.log(num)
// result 14
var num=019
console.log(num)
// Invalid octal 10 Base number 19 Handle
- Hexadecimal must be preceded by 0x( Case sensitive )
var num=0x16
console.log(num)
// result 22
parseInt() It can recognize the value of different base numbers
notes :parseFloat() Only decimal numbers can be parsed
- 0 The following values will be interpreted as octal
var num=parseInt(016)
console.log(num)
// result 14
- 0x The values that follow are interpreted as hexadecimal
var num=parseInt(0x16)
console.log(num)
// result 22
toString() It can return numbers in different hexadecimals by passing in parameters
var num=16
console.log(num.toString())
// result 16
console.log(num.toString(2))
// result 10000
console.log(num.toString(8))
// result 20
console.log(num.toString(10))
// result 16
console.log(num.toString(16))
// result 10
边栏推荐
猜你喜欢

Dataease installation upgrade

Metersphere实现UI自动化元素不可点击(部分遮挡)

How does ETF position affect spot gold price?

数据库系列:有什么办法对数据库的业务表进行无缝升级

Move command

Debug debugging in katalon
![[monkey] Introduction to monkey test](/img/70/5a7152d0b6b77df7f9d6ad0e09e000.png)
[monkey] Introduction to monkey test
![[Li Kou - dynamic planning] sort out topic 1: basic topics: 509, 70, 746, 62, 63, 343, 96 (with links, topic descriptions, problem solving methods and codes)](/img/02/4dbd97c8b8df1c96b7c8e1460aeda2.png)
[Li Kou - dynamic planning] sort out topic 1: basic topics: 509, 70, 746, 62, 63, 343, 96 (with links, topic descriptions, problem solving methods and codes)

Katalon global variable is referenced in testobject

【实操】Appium Settings app is not running after 5000ms
随机推荐
一种跳板机的实现思路
物联网无线通信应用中6种融合定位技术
How to use dataant to monitor Apache apisex
MytipartFile与File的相互转换
Katalon框架测试web(二十)自定义关键字以及上传弹窗操作
fastposter v2.8.4 发布 电商海报生成器
JSON模块、hashlib、base64
MySQL cannot be opened. Flash back
MySQL (I)
无线通信模块定点传输-点对多点的具体传输应用
Realize an air conditioner with compose to bring you cool in summer
【实操】Appium Settings app is not running after 5000ms
MySQL(一)
第六天 脚本与动画系统
港伦敦金行情走势图所隐藏的信息
appliedzkp zkevm(9)中的Bytecode Proof
Minimum stack < difficulty coefficient >
Ffmpeg audio and video recording
[Agora] get an Agora_ Example usage of refptr object
壓縮解壓