1What is the difference between IE and DOM event stream?
① describes how the event is bound:
IE9 before : attachevent ("onclick"), DetachEvent ("onclick")
IE9 Start with Dom event flow is the same, it's all AddEventListener
② the differences between the two binding methods:
the difference in wording:
Attachevent two parameters, event with on
AddEventListener Three parameters , event without on, True/false for capture /bubbling
The difference in functionality:
Attachevent-bound events are all bubbling ,addeventlistener depending on whether the third argument is true or false determines whether to bubble or capture.
③ event bubbling and event capture .
bubbling : When an event is triggered, it starts with the current node and, in turn, triggers the same type of event for its ancestor node.
Capture: start with the root node, triggering its ancestor node-type event in turn, until the node itself.
2What is the compatibility of IE and standard?
ev = e | | window.event;// Gets the event object (event factor):
DOM2 Add Event : if (dom.attachevent) {
Dom. attachevent ("onclick", function);
}else{
Dom. AddEventListener ("click", function);
}
Cancel Event Bubbling : if (e.stoppropagation) {
E.stoppropagation (); outside IE
} else {
E.cancelbubble = true; before IE8
}
Cancel Default event: if (e.preventdefault) {
E.preventdefault (); outside IE
} else {
E.returnvalue = false; Ie
}
What is API 3?
APIs(application Programming Interface, application programming interfaces) are pre-defined functions, The goal is to provide the ability for applications and developers to access a set of routines based on a piece of software or hardware without having to access the source code or understand the details of the internal working mechanism.
in programming languages , APIs often refer to system tools such as functions, interfaces , classes, etc., built into the language . We programmers do not need to care about the implementation details of these functions , just follow the API documentation requirements , to pass the function to the specified parameters to accept the return value .
in front of the background to pass data , API is also provided to the foreground interface , the front desk only need to request the interface and send the specified parameters , the course accepts the JSON string . Example:https://api.douban.com/v2/book/1220562
4JavaScript event processor does not run before the thread is idle what does it mean?
JS is a single-threaded application , that is, when a piece of code is executing , other code must wait until the end of the thread to execute if it needs to be executed.
for (Var i=1;i<=3; i++) {setTimeout (function () {console.log (i); },0); };
When the code executes to a for loop , when the for Loop executes for the first time , the first settimeout is not triggered immediately, because The For Loop also has an end, and now the thread is blocked by the for Loop. The settimeout must wait until the thread for the For loop finishes, that is, after the thread is idle, and this time I has become 4.
so the final print of three 4. Workaround to change Var to let or nested self-executing function in a For loop
the role of callee and caller in 5JS
different wording :
Callee is A property of Arguments that is called in a function using arguments.callee .
Caller is called directly in the function using the function name. Func. Caller
different functions :
Arguments.callee returns a reference to the current function itself !!
Func. Caller Returns the function in which the current function is called . returns null if the function is a top-level call
function func () { console.log (func.caller); } Func (); Null function Func1 () { func (); } Func1 (); Back to Func1
What are the reserved words in 6js ?
pre-defined keywords in the program ( identifier such as function name, class name, property name, method name, and so on ) 's All JS the reserved words in the. These reserved words do not allow the user to declare again as variables, methods, functions
reserved words can change color in the compiler .
7 Factory mode How to create a JS object (multiple ways to create an object in JS)
① literal pattern: var obj = {}
The blending mode is what we call adding attributes to member properties ( constructor mode ) , add the method to the prototype method (prototype mode)
What are the 8js lazy loading methods?
http://blog.csdn.net/dragoo1/article/details/48155501
+ placing the JS Code at the end of the document is also one of the ways to delay loading .
9The difference between Documen.write and InnerHTML?
Documen.write is writing code directly throughout the document . will overwrite other existing code .
InnerHTML is when a node is selected , the code inside the node is modified , affecting only the current node .
The garbage collection mechanism in JavaScript? Memory release in a closure?
The garbage collection mechanism in Js, the variables in the function , are recycled After the function is executed .
however , if a closure is used in a function , the variables in the function will always be held by the internal function , and will not be released after the function has finished executing .
http://www.cnblogs.com/zhwl/p/4664604.html
Two important functions of closures :
① can allow external functions to access variables inside the function.
② lets the variables inside the function not be freed after the function is executed, but always in memory
What operations can cause a memory leak
Use global variables extensively
Extensive use of closures
Clear DOM node , only the nodes are purged and no events are deleted
Http://www.cnblogs.com/libin-1/p/6013490.html
The problem of accuracy in JS
JS in the floating-point arithmetic or large integer operation , may lead to inaccurate results appear . For example , the 0.7+0.1=0.7999999999999 solution can add the number *and divide it by 10.
http://www.cnblogs.com/snandy/p/4943138.html
defer and async
1. Default Reference script:<script type= "Text/javascript" src= "X.min.js" ></script>
When the browser encounters a script tag, The parsing of the document stops, and the script is immediately downloaded and executed , and the document continues to be parsed after the script finishes execution.
2. Async mode
<script type= "Text/javascript" src= "X.min.js" async= "Async" ></script>
When the browser encounters a script tag, the parsing of the document does not stop , the other threads download the script, and the script starts executing the script after the download is complete. During script execution, the document stops parsing until the script finishes executing.
3. Defer ( delay ) mode
<script type= "Text/javascript" src= "x.min.js" defer= "defer" ></script>
when the browser encounters a script tag, the parsing of the document does not stop, and other threads download the script until the document is resolved and the script executes .
http://www.cnblogs.com/xuechenlei/p/5947555.html
Explain what happens to this CSS selector? [Role=nav]>ul A:not ([Href^=mailto]) {}
[Role=nav] Select the element in the page where the role attribute equals nav . That is, the navigation bar
[Role=nav]>ul Sub-node in navigation bar ul
[Role=nav]>ul a UL inside the a label
A:not ([Href^=mailto]) selects the A tag , except for the href attribute that starts with mailto .
Select the a tag that is not mailto in the UL in the navigation bar .
JS Face question Summary