[JS Basics] The difference between i++ and ++i? What is the difference between null and undefined? What is the difference between == and ===? What is the difference between setTimeout and setInterval?

1. What is the difference between i++ and ++i?

i++ :先用i值后加1
++i :先加1后用i值
//计算:var n=5; 求 var num=n++ + ++n + n++ + ++n +n;  //27

2. What is the difference between null and undefined?

undefined是访问一个未初始化的变量时返回的值
null是访问一个尚不存在的对象时所返回的值
因此,可以把undefined看作是空的变量,而null看作是空的对象

3. What is the difference between == and ===?

== 抽象相等,比较时,会先进行类型转换,然后再比较值
===严格相等,判断两个值相等同时数据类型也得相同

4. What is the difference between setTimeout and setInterval?

二者都是用来设置定时操作的

setTimeout: 设置一个定时器,在定时器到期后执行一次函数或代码段

setInterval: 设置一个定时器,以固定的时间间隔重复调用一个函数或者代码段

Guess you like

Origin blog.csdn.net/weixin_43352901/article/details/108750524