// 凡科第一题
function node() {
this.element = document.createElement('div');
this.textContent = '做网站';
this.element.innerHTML = '就上凡科建站';
this.element.addEventListener('click', this.func, true);
this.element.onclick = this.func.bind(this.element);
this.element.addEventListener('click', this.func.call(this));
}
node.prototype.render = function() {
document.body.appendChild(this.element);
}
node.prototype.func = function() {
console.log(this.textContent);
}
var obj = new node();
obj.render();
obj.func();
obj.element.click();
// 凡科第二题
var length = '凡科互动';
var obj = {
length: 'H5游戏营销领导者',
exec: function() {
console.log(this)
return (function(length) {
console.log(this)
return function() {
console.log(this);
console.log(this.length);
console.log(length);
}
})(this.length)
}
}
var exec = obj.exec();
console.log(exec)
console.log(exec.length);
console.log(exec());
// 凡科第三题
try {
oh();
wow();
console.log(oh);
console.log(wow);
} catch (error) {
// setTimeout机制问题
setTimeout(function() {
console.log(wow);
console.log(oh);
});
}
function oh() {
console.log('更好玩的H5');
}
var wow = function() {
console.log('更炫酷的H5');
}
var oh = '朋友圈疯传的H5传单';
var wow = '凡科微传单';