// 凡科第一題
function node() {
this.element = document.createElement('div');
this.textContent = '做網(wǎng)站';
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游戲營銷領(lǐng)導(dǎo)者',
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 = '凡科微傳單';