HTML5 common face questions and answers (b) __html

Source: Internet
Author: User
Tags closure md5 md5 encryption variable scope

1,new characteristics of HTML5

(1) Painting canvas

(2) video and audio elements for media playback

(3) Local offline storage localstorage long-term storage data, browser shutdown after the data is not lost

(4) Sessionstorage data is automatically deleted after the browser is closed

(5) Semantically better content elements, such as Article,footer,header,nav,section

(6) Form control, Calendar,date,time,email,url, etc.

(7) New technology Webworker,websockt,geolocation

(8) moved out of the element

A. Elements of pure expression: Basefont,big,center,font, etc.

B. Elements that have a negative impact: frame frameset, etc.

(9) IE8 7 6 supports the creation of new tags through the Document.createelemet method, which enables these browsers to support HTML5 new labels

2. Semantic Understanding

*html semantics is to make the content structure of the page, easy to browser, search engine analysis;

* In the absence of style CSS is also in a document format, and is easy to read;

* Search Engine crawler relies on the tag to determine the context and the weight of each keyword, conducive to SEO.

* Make it easier for people to read the source code to block the site and to read and maintain understanding. 3, What is the difference between jquery and jquery UI.

(1) jquery is a JS library, mainly provides the function is selector, property modification and event binding and so on.

(2) The jquery UI is based on jquery, using the extensibility of jquery to design plug-ins. Provides some common interface elements, such as dialog boxes, drag behavior, resizing behavior, and so on.

4. Garbage collection mechanism (GC)

We generally say that garbage collection is for memory. Memory is a valuable resource in the computer, and no program can run without it. Since memory can be manipulated by programs, it is necessary to manage memory space in order to prevent memory from being abused by programs. When it comes to memory management, the garbage collection mechanism in JS can not be separated from each other, and there are two strategies to achieve garbage collection: "Mark clear and reference count;"

When the function runs, the browser automatically opens up a piece of memory to the inside of the browser variables, stored in this memory after the end of the operation, the use of the variable, it automatically recycled

5. Closure Package

Because the function internally defines a variable scope problem, if the external want to use this intrinsic function to create a variable; then you need to create a function inside the function that creates a function that is equivalent to a bridge throwing an internal external function variable, which solves the problem of not accessing the variable. That intrinsic function is called a closure.

Characteristics of closures:

A. Nested functions within functions

B. Internal functions can refer to outer parameters and variables

C. Parameters and variables are not reclaimed by the garbage collection mechanism

In a nutshell, a closure is a function that can read the internal variables of other functions, and in essence it is a bridge linking the inside of a function to the outside of a function.

6, cached version update

Principle: Modify the address name of the resource, for the browser, is a new request

Traditional way: Add a version number after "Static resource"

Script (src= "Indexpage.js"?) v=20160227 ")

Advantages: Can solve the problem caused by the cache, can update the cache in time, so that users access to the latest content

Disadvantages: In medium-sized, large projects, version number is generally a unified variable, when only a small change, such as only a JS script has changed, at this time all the resources of the version number are updated, resulting in resource flow waste, user experience is not good

Solution: Change On Demand

Incremental Publishing: The content content of the dependent text changes, and the encrypted string is changed

Advantages: When submitting a resource server, only the new file will be submitted, unchanged file is still the old resources, that is, only add modified files

Disadvantage: After the file is submitted, the updated file, there may be multiple versions, resulting in a waste of space on the server, the need to regularly clean unused resources

Principle: Using MD5 encryption technology

(the need to generate MD5 string of resources read over, use MD5 to encrypt the content of the compilation, generate the corresponding encryption string, this encryption string is unique, if the content of the resource does not change, again MD5 processing, the generated encryption string does not change)

7, the role of TypeOf

For the operand of a numeric type, the value returned by TypeOf is number. For example: typeof (1), the return value is number.

The above is a regular number, and for unconventional numeric types, the result returns a number. For example, typeof (Nan), Nan in JavaScript represents a special Non-numeric value, although it is a numeric type. In JavaScript, there are several special numeric types: Infinity represents infinity Special values

For a string type, the value returned by TypeOf is String. For example, the value returned by typeof ("123") is a string.

For a Boolean type, the value returned by TypeOf is a Boolean. For example, the value returned by typeof (True) is a Boolean.

The values returned for objects, arrays, and Null are object. For example, typeof (window), typeof (document), typeof (NULL) return values are object.

For a function type, the value returned is a function. For example: typeof (eval), the value returned by typeof (Date) is a function.

If the OP count is undefined (for example, a nonexistent variable, function, or undefined), it will return undefined. For example: typeof (SSS), typeof (undefined) all return undefined 8, the common status code represents what

1** (Information Class): Receive the request and continue processing
2** (successful response): To accept, understand, and accept actions
200-Indicates the request was successfully completed and the requested resource was sent back to the client
202-Accept and process, but processing not completed
203-return information is uncertain or incomplete
204-Request received, but return information is empty
3** (redirect): In order to complete the specified action, you must accept further processing
300-The requested resources are available in multiple places
301-This page is permanently transferred to another URL

304-Since the last request, the requested page has not been modified, the server returns this response, does not return the content of the Web page, on behalf of the last document has been cached, you can continue to use
305-The requested resource must be obtained from the address specified by the server
4** (Client Error Class)
400-Client Request syntax error, cannot be understood by the server
403-No access, the server receives the request, but refuses to provide the service
404-The server is unable to obtain the requested Web page and the request resource does not exist.

9. JavaScript Asynchronous loading scheme

Create script, insert into DOM, callback after loading, code as follows:

function Loadscript (URL, callback) {
   var script = document.createelement ("script")
   Script.type = "text/ JavaScript ";
   if (script.readystate) {//ie
      script.onreadystatechange = function () {
         if (script.readystate = = "Loaded" | | Script.readystate = = "complete") {
            script.onreadystatechange = null;
            Callback ();
         }
      ;
   } else {//others:firefox, Safari, Chrome, and Opera
      script.onload = function () {
          callback ();}
      ;
   }
   script.src = URL;
   Document.body.appendChild (script);

10, php-like Print_r functions implemented in JavaScript

function Print_r (theobj) {
    var retstr = ';
    if (typeof theobj = = ' object ') {
        retstr + = ' <div style= ' font-family:tahoma; font-size:7pt; " > ';
        For (var p in theobj) {
            if (typeof theobj[p] = = ' object ') {
                retstr + = ' <div><b>[' +p+ '] => ' + typeo F (theobj) + ' </b></div> ';
                Retstr = ' <div style= ' padding-left:25px; > ' + print_r (theobj[p]) + ' </div> ';
            } else {
                Retstr + = ' <div>[' +p+ '] => <b> ' + theobj[p] + ' </b></div> '
            ;
        }
        Retstr + = ' </div> ';
    }
    return retstr;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.