前端面试问题集
2015-10-25 21:06
501 查看
Ways to define functions Function Declration: function functionName(param1) {} Anonymous Function: var functionName = function(param1) {}; Function Constructor: var myFunction = new Function(“a”, “b”, “return a * b”);
What is Javascript Event Delegate? To bind the event listener to the parent of an html element. The reason for doing this is to easier adding and removing event listeners. For example, li inside ul, to do event delegation. We bind the click listener to ul, and then useevent.target.nodeName to find if it’s the exact node we want to bind the event to. More examples see http://davidwalsh.name/event-delegate
Explain how this works in JavaScript
What do you think of AMD vs CommonJS?
Explain why the following doesn’t work as an IIFE: function foo(){ }();. Need a () to wrap the function body and declarations.
IIFE: An immediately-invoked function expression (or IIFE, pronounced “iffy”) is a JavaScript design pattern which produces a lexical scope using JavaScript’s function scoping.
What’s the difference between a variable that is: null, undefined or undeclared? How would you go about checking for any of these states? undeclared:
A variable is undeclared when it does not use the var keyword. It gets created on the global object (that is, the window), thus it operates in a different space as the declared variables. undefined:
Something is undefined when it hasn’t been defined yet. If you call a variable or function without having actually created it yet the parser will give you an not defined error. null:
null is a variable that is defined to have a null value.
undeclared variables don’t even exist
undefined variables exist, but don’t have anything assigned to them
null variables exist and have null assigned to them First, use typeof to check the type of variable
Second, null == undefined is true, null === undefined is false
What's the difference between host objects and native objects?
What is Javascript Event Delegate? To bind the event listener to the parent of an html element. The reason for doing this is to easier adding and removing event listeners. For example, li inside ul, to do event delegation. We bind the click listener to ul, and then useevent.target.nodeName to find if it’s the exact node we want to bind the event to. More examples see http://davidwalsh.name/event-delegate
Explain how this works in JavaScript
Function:
this point to the function itself.Object:
When a function is called as a method of an object, its this is set to the object the method is called on. Simply speaking, this is pointing to one upper level of the element in most case. Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/thisWhat do you think of AMD vs CommonJS?
Explain why the following doesn’t work as an IIFE: function foo(){ }();. Need a () to wrap the function body and declarations.
1 | (function foo() {})() |
What’s the difference between a variable that is: null, undefined or undeclared? How would you go about checking for any of these states? undeclared:
A variable is undeclared when it does not use the var keyword. It gets created on the global object (that is, the window), thus it operates in a different space as the declared variables. undefined:
Something is undefined when it hasn’t been defined yet. If you call a variable or function without having actually created it yet the parser will give you an not defined error. null:
null is a variable that is defined to have a null value.
undeclared variables don’t even exist
undefined variables exist, but don’t have anything assigned to them
null variables exist and have null assigned to them First, use typeof to check the type of variable
Second, null == undefined is true, null === undefined is false
What's the difference between host objects and native objects?
相关文章推荐
- 我在雅虎获得的 8 个最好的职业建议
- 程序员的出路
- JAVA多线程面试题
- 如何写好简历及如何准备面试(转)
- 月薪3万的程序员都避开了哪些坑
- 程序员编程面试取胜的8个技巧
- JAVA常见面试题
- 一个java程序员自学IOS开发之路(二)
- 面试
- java面试题
- 据说是网易游戏面试题
- 程序员必读书单
- 空格替换(LintCode)
- 去哪儿网、腾讯实习面试总结-
- JAVA学习课第二十八届(多线程(七))- 停止-threaded多-threaded面试题
- 推荐程序员值得看的书籍
- IT笔试面试智力题
- 字符大小写排序(LintCode)
- 程序员怎样快速赚到一百万?
- 《程序员面试金典》--寻找二叉树中某个节点中序遍历的下一个节点