有趣的前端面试问题
via https://github.com/darcyclarke/Front-end-Developer-Interview-Questions
Can you describe the difference between progressive enhancement and graceful degradation?
- Bonus points for the answer “no one can”
- Extra bonus points for describing feature detection
IIFEs - Immediately Invoked Function Expressions 控制 variable scope
(function () {
// your code here
})();
What’s the difference between host objects and native objects?
Difference between:
function Person(){}
var person = Person()
var person = new Person()
hoisting 变量声明提升
~~3.14 去掉小数(比 Math.floor 效率高)
Use double bitwise NOT when:
- You want to convert the number from float to integer.
- You want to perform same operation as Math.floor() but a lot quicker.
- You want to minimalize your code.
Do not use double bitwise NOT when:
- You run Google Chrome (apparently?).
- You care about readability of your code.
FOUC 页面闪烁
Explain the difference between the JavaScript call and apply functions.
The main difference is that apply lets you invoke the function with arguments as an array; call requires the parameters be listed explicitly.
apply 参数是数组;call 参数逗号分隔
theFunction.apply(valueForThis, arrayOfArgs)
theFunction.call(valueForThis, arg1, arg2, …)