Learning JavaScript Tutorials: JS face questions (with answers)

Source: Internet
Author: User
Tags array object html page sort variable window access javascript array

Article Introduction: a complete set of JavaScript face test questions.

One, single topic 1, which of the following statements will produce a run-time error: (a,d) A.var obj = ();   B.var obj = [];       C.var obj = {}; D.var obj =//;
2. Which of the following words does not belong to the JavaScript reserved word: (b) a.with b.parent C.class d.void
3. Please select an expression with the result to be true: (b) instead C) a.null instanceof Object b.null = = undefined C.null = undefined D.nan = = NaN
Second, the indefinite item choice Question 5, the Foo object has the ATT attribute, then obtains the Att property the value, which the following practices are possible: (B,d to a\ c\e) A.foo.att b.foo ("att") c.foo["att"] d.foo{"att"} E. Foo["a" + "T" + "T"]
7. Which of the following are global functions of javascript: (a,b,c,d,e) a.escape b.parsefloat c.eval d.settimeout E.alert
10, about IE, the window objects are stated correctly: (A,B,C,D) The A.window.opener property itself is pointing to the Window object B.window.reload () method can be used to refresh the current page c.window.location= The role of "a.html" and window.location.href= "a.html" is to replace the current page with the a.html page D. Defines the global variable G; You can access the variable in a WINDOW.G way
Third, questions and answers: 1, talk about the use of JavaScript array sorting method sort (), focusing on the use of sort () parameters and its internal mechanism answer:

Syntax: Arrayobject.sort (SortBy)

Parameter sortby: Optional, specify sort order. Must be a function.

Returns a reference to an array. Note that the array is sorted on the original array and no replicas are generated.

If the method does not use parameters, it is sorted in the order of character encoding.

If you want to sort by other criteria, you need to provide a comparison function that compares two values, and then returns a number that describes the relative order of the two values. The comparison function should have two parameters A and B, and the return value is as follows:

1 if a is less than B, in the sorted array, a should appear before B, returning a value less than 0.

2 If a equals B, return 0.

3 If A is greater than B, it returns a value less than 0.

Example: Sort by number

<script type= "Text/javascript" > Function Sortnumber (a,b) {return a-b} var arr = new Array (6) arr[0] = "Ten" arr[1 ] = "5" arr[2] = "arr[3] =" "arr[4] =" 1000 "arr[5] =" 1 "document.write (arr +" <br/> ") document.write (ARR.S ORT (Sortnumber)) </script>
2. Briefly describe the difference between DIV elements and span elements. A, Div is a block element, the default line wrap, generally used for typesetting.

B, span is inline elements, the default does not wrap, generally used for local text styles.

C, through display properties they can be converted to each other, div defaults to block,span default for inline.

3, combining text This paragraph structure, talk about the difference between innerHTML outerhtml innertext. For:

InnerHTML: The HTML content inside the object, this is <span id= "inner" >text

outerHTML: The object contains the HTML content of the object itself, this is <span id= "outer" ><span id= "inner" >text

InnerText: Text content in Object

4, say a few XHTML specification content (at least 3 article) answer:

1) The label name must be in lowercase letters.

2 All tags must be closed, including empty tags.

3 attribute values must be quoted.

4 replaces the Name property with the id attribute.

5 All XHTML documents must be file type declaration.

5, on the Web Standardization (or Web site refactoring) know what the relevant knowledge, briefly describe a few you know the Web standards? For:

Why use Web standards?

1) with better compatibility.

2 Easy code maintenance and development.

3) can increase the number of visits to the site.

4 standard Web documents are more easily converted to other formats.

5 is more easily accessed by search engines, and is more easily indexed accurately.

6 is easier to access by JavaScript and Dom code.

The standard for the consortium: HTML, XHTML, CSS, XML, XSL, DOM.

Four, the procedure question:1, complete the content of the Foo () function, ask to be able to pop-up dialog box prompts the currently selected is the first few radio boxes. }) (i)} return false;} </script> <body> <form name= "Form1" > <input type= "Radio" name= "Radiogroup"/> <input "type=" Radio "name=" Radiogroup "/> <input type=" Radio "name=" Radiogroup "/> <input type=" Radio "name=" Radiogroup "/ > <input type= "Radio" name= "Radiogroup"/> <input type= "Radio" name= "Radiogroup"/> <input "type=" Submit "/> </form> </body>
Related Article

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.