面试题

有关面试题:

setTimeout(function(){
		console.log(4);
	},0);
	console.log(3);
	new Promise(function(resolve){
		console.log(1);
		resolve();
		console.log(2);
	}).then(function(){
		console.log(5);
		return 7;
	}).then(function(i){
		console.log(i);
	});
	console.log(6);
输出结果:  3 1 2 6 5 7 4
var arr = [];
arr.prototype ===  undefined
arr.__proto__ === Array.prototype
Array.__proto__ === Function.prototype
Array.prototype.__proto__ ===  Object.prototype
var test = {
		name: 'myname',
		name2: this.name,
		getName : function(){
			return this.name;
		},
		getName2 : function(){
			setTimeout(function(){
				console.log(this.name);
			},1000)
		},
		getName3 :function(){
			setTimeout(()=>{
				console.log(this.name);
			},1000)
		}
	}
	console.log(test.name2);
	console.log(test.getName);
	test.getName2();
	test.getName3();              //myname

js实现数太大导致后面的数为零,两个字符串相加
参考学习:https://blog.csdn.net/Q1059081877Q/article/details/80689194

posted @ 2019-05-10 17:04  princeness  阅读(76)  评论(0编辑  收藏  举报