Home > database >  The front-end based small knowledge
The front-end based small knowledge

Time:09-28

1. Introduce the define
Define is amd (asynchronous) module loading mechanism of API, the first parameter is the module name (optional), the second parameter is an array, containing all the dependent module (optional), the third parameter can be a function or a js object,
Three parameters: (1) if the third parameter is the callback function, after induction load dependent module, implement the callback function, can be used directly in the callback function dependent module, they according to the sequence of statements rely on as a parameter for the callback function, the callback function to perform after the notification depends on one's own modules are available,
(2) two parameters: when the first parameter is omitted, it defines an anonymous module, this module file filename is the module name, which will make the module is highly available,
(3) a parameter: define the front of the two parameters can be omitted; The third argument has two situations: one kind is a JavaScript object, another is a function,
?? If is an object, can be contains the method's object or only provides the data, which is very similar and json, therefore, AMD that contains a complete the json implementation, module evolved into a simple data object, data object is highly available, and because is a static object, it is also the CDN friendly, can improve the performance of the json,
?? If it is a function, one of the purposes is to rapidly develop, suitable for the application of the smaller, the way no need to think ahead into modules, simply, when using the require,

Define (function () {
Var a=the require (" a ");
})
Define function at the time of execution, will call a function of the toString method, and scan the require of these calls, loaded in these modules, after completion of loading and execution,
Note: Opera cannot very good support function's toString method, therefore, its applicability is not strong in the browser, but use the build tool package, build tool will scan the require dependent module and force loading,

2. Express what is it?
Express is a minimal, flexible Node. Js Web application development framework, it provides a set of powerful features to develop Web and mobile applications, it helps the Node based Web application of rapid development,
Features: 1, you can set the middleware in response to a HTTP request
2, and defines the routing HTTP requests to perform different actions
3, can be passed through the template parameters to dynamic rendering HTML page

3. What is the require?
Asynchronous load module loader
4. Var, let, const difference between
(1) the var is variable ascension, let and const does not exist variable, so can only be used after the variable declarations, otherwise complains,
(2) the const immutable, stating, initialized directly, var, let can modify, but if the const point is a reference value, you just need to ensure that the address of the reference values do not change,
(3) the let and const are block-level scope, var is the function scope,
(4) the let, const are not allowed in the same scope statement the same variable,
5. Which used PC and mobile client framework?
PC: vue. Js, the bootstrap, jQuery, zepto, node. Js,
Mobile client framework: zepto
6. Event bubbling, delegation and events to capture?
Event bubbling is child elements of an event is triggered, of the parent element of this event is recursive implementation, is the end point of the bubble of the window,
Stop event bubbling on the child elements plus e.s topPropagation () to stop event bubbling,
Event delegation is to use the principle of the bubble, actually from click element, recursive way of dissemination of events to the parent element is the benefits for a large number of elements to be processed, don't have to be for each element binding event, only need to their parent element binding a can, improve performance, there is another advantage is that can handle dynamic insert in the dom elements, is not directly binding way,
Capture is one of the most outer events first is triggered, the last is we click on the button of the event is triggered, this is the event capture,
Way to stop event capture is e.s topPropagation (),
7. On the bind, live (jQuery)
the difference betweenBind is used to bind to one or more events,
Live a and multiple event can also be bound, but it can also be as a new element binding event,
On is the combination of the former two ways, not only on method is more than a selector, namely subclass selector, events can also entrust

$(" div ") on (" click ", "p", the function () {
alert(1);
})
8. The call, the difference between the apply, bind
Thing in common: they were in the call, dynamic specified in the function this
Difference: 1. The call, the apply to borrow, temporary binding; 2. The bind permanent binding
Return value: 1. The call, the apply does not create a new function, just call the function; 2. Bind based on function, creating a new object function, then the call is actually a new function object
Parameters: 1. The call, apply at the time of call incoming call all parameters, independence to each parameter, the apply of the parameter in the array, uniform incoming; 2, bind early binding part in creating a function parameter, the function passes the rest parameters,
Due to 6 ~ 8 does not support the bind, so need to be compatible with:

if (! The function () {}. The bind) {
The Function prototype. Bind=Function (context) {
Var self=this
, the args=Array. Prototype. Slice. The call (the arguments);

Return the function () {
Return the self. The apply (context, args. Slice (1));
}
};
}
9. In the front-end development, a number of user behavior will often trigger events, for the DOM manipulation, the processing of resource loading cost performance, is likely to lead to caton, even the collapse of the browser, stabilization and throttling is in order to solve this kind of problem,
10. How much do you know common HTTP status code? Describe the following status code
(1) 200, request success
(2), 301 permanent redirect, the browser will automatically connect to the new URL,
(3), 302, a temporary redirect, want the user to (the), can be accessed using the new URI
(4), 303, the status code should use the GET method request for resource oriented
(5) 403 server refused to perform the task, there is no access to
(6), 404, the NOT, found the requested resource, web page cannot be found, there is no
(7), 503, the server can't response,
  • Related