重学js1

一.命名

1.尽量字母开头字母结尾

2.构造函数以大写字母开头,避免方法(少用构造函数)

3.名字中不允许存在空格,原因在于早期编译器的内存管理,后期未修改规则

4.保留字

  arguments await break case catch class const continue debugger default delete do else
  enum eval export extends false finally for function if implements import in Infinity
  instanceof interface let NaN new null package private protected public return static
  super switch this throw true try typeof undefined var void while with yield
二.数值
1.js中只有一个数值类型number,不存在溢出。1符号位+11位指数位+53位有效位数
2.其他编程语言的浮点数的实现:有效位数(系数/分数/尾数)+指数(小数点位置).代表值=符号位(正/负)+有效位数+(2**指数) 指数还可以表示NAN,Infinity(大到无法表示的值)以及非规格化浮点数(特别小的数和0)
3.Number.EPSILON是js中最小正整数,Number.MAX_SALE_INTEGER为最大安全整数。最大安全整数和最小安全整数之间的整数统称为安全整数,Number.isSafeInteger()函数来确认是否安全整数,Number.isInteger()函数判断是否整数,Number.MAX_VALUE是js中数值类型的最大值.Number.MIN_VALUE刚好比0大的最小正数。
 4.运算符

 5.Math对象

  Math.floor() 返回最靠近传入参数的整数

  Math.trunc()返回恰比传入参更接近0的整数

  Math.random()  Math.min()  Math.max()

 

 
 
 
posted @ 2023-07-17 11:23  月下云生  阅读(19)  评论(0)    收藏  举报