-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
点滴记录(javascript) #5
Labels
Comments
6 . 取整~~3.125522 // 3
0|3.125522 // 3
parseInt(3.125522) // 3
Math.floor(3.125522)
~~0.0000000003 // 0
parseInt(0.0000000003) // 3
Math.floor(0.0000000003) // 0 因为 0.0000000003 会使用科学计数法表示为 3e-10,parseInt 会首先把参数转换为字符串,然后解析整数,直到遇到不是数字的值。 parseInt('2017-05-02') // 2017 parseInt('-0') // -0
parseInt(-0) // 0 特殊情况,如果你的返回值是整数(int32),那么可以使用位运算。使用位运算就不需要再去考虑那些非常规的值 NaN、undefined、null 等,这些值都是 0。0也只有唯一的值,不存在 +0 和 -0。 |
7 . 解构在数组上面的应用const {0:a, 2:b, length:l} = ['foo', 'bar', 'baz']
a // 'foo'
b // 'baz'
l // 3 const { length: l, [l-1]: last } = ['foo', 'bar', 'baz']
l // 3
last // 'baz' const { ...obj } = [1,2,3]
obj // {0: 1, 1: 2, 2: 3} |
9. 一行代码实现数组求和var a = [1, 2, 3, 4, 5];
a.reduce((a, b) => a + b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1 .
token
是 词法单元的意思我们经常在看到js的报错信息
token
就是 词法单元的意思将代码分解成有意义的代码块,这些代码块成为
词法单元 (token)
2 . JS常见异常类型
我们一般都是抛出一个自定义的异常,那JS本身常见的异常类型有哪些那?
3 . 阻止冒泡及默认行为
e.preventDefault();
e.stopPropagation();
4 . javascript语言是传值调用
5 . 逻辑运算返回的不是 true | false
逻辑就是测试 真 或 假,真假不是字面量true 或 false
js本身帮你进行了转换,空字串、undefined 0 null false 这5个返回false,其他的都是true
The text was updated successfully, but these errors were encountered: