记一次面试
来源:互联网 发布:李安 知乎 编辑:程序博客网 时间:2024/06/05 20:09
1.作用域问题
function b() {
console.log(myVar)
console.log(myVar1)
}
function a() {
var myVar = 2
var myVar1 = 3
b()
}
var myVar = 1
a()
console.log(myVar1)
2.原型及继承
function Tree() {}
Tree.prototype.MoreLeaf = function() {
this.leaf++
console.log('i have' + this.leaf + 'Leafs')
}
Tree.prototype.leaf = 0
var tree1 = new Tree()
tree1.MoreLeaf()
tree1.MoreLeaf()
var tree2 = new Tree()
tree2.MoreLeaf()
输出:
实现AppleTree继承Tree,实现确认AppleTree是继承Tree
3.闭包问题
for (var i=1; i<=3; i++) {
setTimeout(function() {
console.log(i)
}, 1000)
}
4.js事件执行顺序
下面事件在页面执行以后,10秒之内连续点击3次,输出结果如何
function a() {
var ms = 1000 + new Date().getTime()
while(new Date() < ms) {}
console.log('event waiting')
}
function b() {
console.log('event click')
}
document.addEventListener('click', b)
a()
console.log('event exuted')
5. 实现函数,用来判断两个参数相等
- 【面试总结】记一次面试
- 记一次非正式面试
- 记一次面试经历
- 记一次实习面试
- 记一次PHP面试
- 记一次电话面试
- 记一次面试
- 记一次面试经历
- 记一次阿里面试
- 记一次实验室面试
- 记一次网易面试
- 记一次面试经历
- 记一次模拟面试
- 记一次面试
- 面试总结 | 记一次Android 面试
- 记 一次“奇葩”的面试
- 记一次IBM面试经历
- 记一次糟糕的面试
- HDOJ1587 Flowers
- Redis
- [Machine Learning]Kmeans 算法 python 实现
- 结构体小知识
- 1008. Elevator (20)
- 记一次面试
- python:运算符
- Web
- 以/为单位截取URL
- SQL学习之双向表头报表查询
- 使用Git管理代码
- Python的几个问题
- Entity Framework(3)删除
- echarts统计图json格式数据来自单元格