Common questions distal surface (js, html, css)

1. Closure
(1) is a closure function, two functions nested within each other, forming the internal closure function is that the internal closure function needed to return back through it
(2) ①, the closure is capable of reading other function function of internal variables.
   ②, the internal functions and external functions to connect the bridge
2.localstorage, session, cookie difference
1.cookie always in the http request homologous to carry, even if do not need, cookie passed back and forth in the browser and the server. LocalStorage and sessionStora while only in a local storage, the communication server will not be good, does not automatically send data to the server.
2. Storage of different sizes, cookie about 4kb; localStorage, sessionStorage can reach 5M
3. Different data is valid, sessionStorage valid only in the homologous window, close the window disappears, cookie you can set an expiration time, localStorage long-term effective
localStorage, sessionStorage there are ready-made API, cookie programmers need to manually package

3.http common status code
100 Continue to continue, usually in the post request transmission, http header has been sent after the server returns this message, to confirm, after the transmission of the specific parameter information
200 OK normal return information
201 Created request was successful and the server created new resources
202 accepted server has accepted the request, but has not yet processed
page 301 moved permanently requested has been permanently moved to a new location.
302 Found temporary redirect.
303 See Other temporary redirect, and always use the new GET request URI.
304 Not Modified since the last request, the requested page has not been modified.
400 Bad Request Server can not understand request format, the client should not attempt to use the same content again initiated the request.
401 Unauthorized unauthorized request.
403 Forbidden Forbidden.
404 Not Found Resource not found how to URI to match.
500 Internal Server Error The most common server-side error.
503 Service Unavailable server is temporarily unable to process the request (which may be overloading or maintenance).
4. What happened to enter the URL from the page load
1.DNS analytical
2.TCP connector
3. HTTP request transmission
4. The server processes the request and returns the HTTP packet
5. The browser parses rendering pages
6. Connect the end
5. How to optimize site performance
1. page layers:

  • Reduce HTTP requests: merge files, CSS sprites, inline Image
  • Reduce the number of DOM elements
  • Components preload
  • Non-essential components lazy loading
  • Reduce the number of DOM elements
  • Reducing the number of iframe
    2.serve layer
  • Use CDN
  • Add Expires or Cache-Control header response
  • Components that use Gzip compression
  • Avoid empty img src tag of
  • Use Ajax GET request
  1. js, picture layer, css
  • Optimization cookie
  • Reduce the size of the cookie
  • Do not include the introduction of the resource domain cookie
  • js 1. The script in the bottom of the page
      2. javascript and css introduced from the outside
      3. compressing javascript and css
      4. delete unwanted script
      5. Reduce DOM access
      6. reasonable design event listeners
  • Optimize your images:
  • 1. The need to select the actual color color depth, compression
    1. Css optimization wizard
      - 3. Do not stretch the picture in HTML
      - 4. ensure favicon.ico small and cacheable

6. introduced to redraw and reflux (Repaint & Reflow), as well as how to optimize

  • Change the background color, border, font color, the process of the browser to redraw the color is called redraw
  • When the (width, height, position, create elements) elements of the page changes, will cause the entire page rearrangement, the browser will recalculate structural position, to re-render the page, called DOM reflux

Must redraw reflux occurs, redraw will not necessarily lead to reflux

7. Data Type
1. Analyzing array
typeof not do
two methods: (the instanceof. 1 (2) the isArray
2. basic data types and the reference data type
primitive types: boolean, null, undefined, number , string, symbol
reference data types : object array function
difference between the shake and the throttle

  • Image stabilization function
    when the event to keep firing certain period of time no longer trigger event, the event handler will be executed once, if before the set time comes, they triggered the event, on the re-start delay. That is the case where a user has triggered this function, and the function of each trigger interval is less than a predetermined time, then the anti-shake only once
  • Throttling function
    when the event to keep firing, to ensure that the event handler is called once only within a certain period of time, meaning that, assuming that a user has triggered this function and each time the trigger is less than the predetermined value, the function will be called every throttle this time a
    html5 new features
    1. the new semantic tags
Published 27 original articles · won praise 0 · Views 417

Guess you like

Origin blog.csdn.net/weixin_40542544/article/details/104649544