坑题

来源:互联网 发布:电脑怎么清理软件 编辑:程序博客网 时间:2024/06/15 07:13
(function(){     'use strict'     var a=b=3//这儿由于严格模式,将会出错 })() console.log(a) console.log(b) //Uncaught ReferenceError: b is not defined,a不会打印

关于严格模式:戳这里

var p=new Promise(function(resolve){    console.log(1)    resolve()}).then(function(){    console.log(4)})console.log(2)console.log(3)//1 2 3 4
setTimeout(()=>console.log(4),0)var p1=new Promise(function(resolve,reject){    console.log(6)    setTimeout(()=> console.log(3),0)    resolve('hello')}).then(function(val){    console.log(val)})setTimeout(()=> console.log(2),0)console.log(5)//6 5 hello 4 3 2
var length = 10function fn(){    alert(this.length)}var obj = {    length: 5,    method: function(fn) {        fn() // 10        arguments[0]() // 1    }}obj.method(fn)
function f1(){};var f2 = function(){};var f3 = new Function('str','console.log(str)');var o3 = new f1();var o1 = {};var o2 =new Object();console.log(typeof Object); //functionconsole.log(typeof Function); //functionconsole.log(typeof o1); //objectconsole.log(typeof o2); //objectconsole.log(typeof o3); //objectconsole.log(typeof f1); //functionconsole.log(typeof f2); //functionconsole.log(typeof f3); //function 
0 0
原创粉丝点击