前端工程师面试题总结 - JavaScript(1)
来源:互联网 发布:h网络是什么意思 编辑:程序博客网 时间:2024/05/19 06:17
1. Describe closure
Simply accessing variables outside of your immediate lexical scope creates a closure.
For example:
var test = function () {
var count = 0;
var addOne = function(){ count += 1;}
return addOne;
}
var t = test(); // here t refers to the addOne function, and since addOne refers to the test object, the whole test object will be stored in the RAM
t(); // now the count equals to 1
2. What is event bubbling
Event bubbling and capturing are two ways of event propagation in HTML DOM.
In bubbling the event is first captured and handled by the inner most element and then propagated to outer elements.
In capturing the event is first captured by the outer most element and propagated to the inner most element.
Both are part of the W3C standard. As per the standard first the event will capture it till it reaches the target then it will bubble up to the outer most element.
We can use the addEventListener(type, listener, useCapture)
to register event handlers for bubbling and capturing phases. To use the capturing phase event handling pass the third argument as true
.
IE uses only event bubbling where as firefox supports both bubbling and capturing.
Only event bubbling model is supported by all the major browsers.So if you are going to use event capturing still you need to handle event bubbling for IE. So it will easier to use event bubbling instead of capturing.
P.S: other questions like have you used Angular.js, node.js, or any other similar libraries. Learn as much as you can.
0 0
- 前端工程师面试题总结 - JavaScript(1)
- 前端工程师面试题总结 - HTML(1)
- 前端工程师面试题总结 - CSS(1)
- 前端工程师面试题总结 - Coding(1)
- 前端工程师面试题
- 前端工程师面试题
- 前端工程师面试题(一)
- JavaScript前端常见算法面试题总结
- 初级前端工程师面试题(网上收集的总结)
- 前端开发工程师面试题
- web前端工程师面试题
- 前端初级工程师面试题
- 前端初级工程师面试题
- 前端工程师面试题汇总
- 前端工程师面试题汇总
- 前端工程师面试题汇总
- 前端工程师面试题汇总
- 前端工程师面试题汇总
- fork,printf缓冲
- 码实平台移动端SDK手册
- Autodesk Vault 二次开发介绍之Web Service开发
- UML
- 辛星漫谈软件思想
- 前端工程师面试题总结 - JavaScript(1)
- 云编程那些事2 - Java之父的啤酒密谋
- 前端工程师面试题总结 - Coding(1)
- 展示glfw回调函数,鼠标 键盘 窗口等等,输入输出都齐了
- how to convert a object to json file immediately during debug?
- 最小正子串问题
- 最长回文子串
- C++11 Async cURL
- 辛星浅谈大型网站构架优化思路之一简化