笔试题

笔试题

# 一. 原型,异步和 this 指向

//一:有一个类如下

function Person(name) {
  this.name = name
}
let p = new Person('Tom');
//1: p.__proto__等于什么? Person.prototype
//2: Person.__proto__等于什么? Function.prototype

//二:请写出下面console的值
var foo = {},
F = function({};
Object.prototype.a = 'value a';
Function.prototype.b = 'value b';
console.log(foo.a)
console.log(foo.b)
console.log(F.a)
console.log(F.b)
//value a   undefined    value a    value b

//三:如下console的值是?

function Person (name) {
  this.name = name;
}
function Student () {}
Student.prototype = Person.prototype;
Student.prototype.constructor = Student;
let s = new Student('Tom');
console.log(s instanceof Person);
//true

//四:下面代码输出什么?
for(var i = 0; i < 10; i++) {
  setTimeout(() => {
    console.log(i)
  }, 0)
}
//10个10

//五:下面的结果是什么
console.log('a');
setTimeout(() => {
  console.log('b');
}, 0);
console.log('c');
Promise.resolve().then(() => {
  console.log('d');
}).then(() => {
  console.log('e');
});

console.log('f');
//a c f d e b

//六:如下console的值是?
var User = {
  count: 1,
  getCount: function() {
    return this.count;
  }
};
console.log(User.getCount()); // what?
var func = User.getCount;
console.log(func()); // what?
//1 underfined

//七:回答以下代码,alert的值分别是多少?
var a = 100;
function test(){
  alert(a);
  a = 10;
  alert(a);
}
test();
alert(a);
//100 10 10
代码规范

代码规范

JS图形计算

JS图形计算