JavaScript Complete Interview Questions

Source: Internet
Author: User
Tags gettext javascript array

A single selection

1. Which of the following statements will produce A run: (A)

A.var obj = ();

B.var obj = [];

C.var obj = {};

D.var obj =//;

b is the array, C is the object, and D is the regular expression

2. Which of the following words does not belong to JavaScript reserved words: (B)

A. With

B. Parent

C. Class

D. void

abstract

break

· byte

case

· Catch

char

· Class

const

· Continue

default

· Do

double

extends

final

· Finally

float

· For

int

long

· Native

new

· Null

package

· Private

protected

· Public

· Super

· Switch

· Synchronized

· This

· Throw

· Throws

· Transient

· True

· Try

· Var

· void

· While

· With

3. Select the result as true expression: (C)

A. Null instanceof Object

B. Null = = undefined

C. Null = = undefined

D. Nan = = Nan

A->false,b->false,c->true,d->false,nan is a number that is not equal to any number

Second, the indefinite choice question

4. Please choose to understand JavaScript incorrectly: (ABC)

A. JScript is a javascript abbreviation

B. JavaScript is a Java scripting language developed by Netscape to simplify the development of Java

C. There are a number of compatibility issues with Firefox and IE because of their differences in JavaScript support

D. Ajax technology must use JavaScript technology

C-> is different for Web Standard support, D->ajax full name is asynchronous JavaScript and XML, will use JS technology (but this problem has objection)

5, Foo object has the att attribute, then gets the value of the Att property, which of the following practices is possible: (ACE)
A. Foo.att
B. Foo ("Att")
C. foo["ATT"]
D. foo{"Att"}
E. foo["a" + "T" + "T"]

6. What kinds of HTML tags can enter text manually without specifying special attributes: (AB)

A. <TEXTAREA></TEXTAREA>
B. <input type= "text"/>
C. <input type= "hidden"/>
D. <DIV></DIV>

Note that it is entered manually, so the div can not

7. What are the global functions of javascript: (ABCDE)
A. Escape
B. parsefloat
C. Eval
D. setTimeout
E. Alert

The A->escape () function encodes the string so that it can be read on all computers.

B->parsefloat () parses a string and returns a floating-point number.

C->eval () computes the JavaScript string and executes it as script code.

The global functions in JS are:

8, about the IFRAME statement is correct: (ABCD)
A. Through an IFRAME, a Web page can embed other Web content and can dynamically change
B. Under the same domain name, the embedded IFRAME can get the object of the outer page
C. Under the same domain name, the outer page script can get objects within the IFRAME Web page
D. The size of the IFRAME can be adjusted by script

9. The correct statement of the form is: (ABCDE)
A. The table can contain TBODY elements
B. The table can contain caption elements
C. Tables can contain multiple tbody elements
D. The table can contain colgroup elements
E. The table can contain COL elements

A->tbody table body content, b->caption table title, d->colgroup column grouping, e->col thinning column grouping because there may be differences in each column in a group

The explanation of Colgroup and Col

if the first three columns of a table are vertical, and the last two columns are vertically, we can set them in groups. It appears to be a feature that the stylesheet can replace, but this is not a redundant label, as is the case with the previous label, which is also allowed in XHTML 1.0 Strict.
<table border= "1" >
<colgroup span= "3" valign= "Top" ></colgroup>
<colgroup span= "2" valign= "Bottom" ></colgroup>
<tr>
<td>1 Vertical </td>
<td>2 Vertical </td>
<td>3 Vertical </td>
<td>4 Vertical </td>
<td>5 Vertical </td>
</tr>
</table>
span is used to indicate how many columns the group contains.
The role of Col is to refine colgroup, because even in a group, there may be some differences between columns and columns, and Col is used.
<colgroup span= "3" valign= "Top" >
<col width= "></col> "
<col align= "center" ></col>
<col valign= "Middle" ></col>
</colgroup>
you can see that the valign of the third column overrides the Colgroup valign setting. Here the width, align, valign are all XHTML 1.0 Strict, but note that there is no height property.

10. The window object of IE is stated correctly: (ACD)
A. The Window.opener property itself is A pointer to the Window object
B. The Window.reload () method can be used to refresh the current page
C. The role of window.location= "a.html" and window.location.href= "a.html" is to replace the current page with a a.html page
D. Defines the global variable G; You can access the variable in a WINDOW.G way

A-> such as two pages a a a B,a page in the page to window.open (' b.html ') opened a new window opened B, and on the B page want to get the element on page A to change that element, So the B page uses the window.opener.document.getElementById ("name"). Value = ' newName '; go to change values. So Window.opener is the equivalent of finding the page that opens itself.

B-> no Window.reload () is location.reload () or window.location.reload ()

Three, simple answer

1, talk about the use of the JavaScript array sorting method sort (), highlighting the use of the sort () parameter and its internal mechanism

  Sort () When no arguments are arranged by character encoding, a function should be passed when there are parameters, sorted in the order of the function

such as sort (sortnum);

function Sortnum (A, b) {

return a-B;

}

2. Briefly describe the difference between a DIV element and a SPAN element.

 Div is a block-level element, the width is highly functional, and the span is an inline element (inline element) can be arranged side by side, the width of height does not work, the margin and padding are not valid around

3, combined with <span id= "outer" ><span id= "inner" >text</span></span> this section of structure, talk about innerHTML outerhtml Innerte The difference between XT.

The difference between innerhtml,innertext,outerhtml

innerHTML gets <span id= "inner" >text</span>

InnerText Gets the text

outerHTML get <span id= "outer" ><span id= "inner" >text</span></span>

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

  Tag closure, label name must be lowercase, properly nested, must have root element, all XHTML elements must be nested within the root element

5, to the Web standardization (or site reconstruction) know what the relevant knowledge, briefly describe a few of the Web standards you know?

  Web standardization is divided into structural standardization, performance standardization, behavior standardization. The structure standard language has XHTML and XML, the performance standard language CSS, the behavior standard language w3c,ecmscript

Web standardization is a method of website reconstruction

6. How to get the text of Form <select> field Selection section

<select id= "se" onchange= "getText ()";
<option value=" 1 ">11111</OPTION>}
<option value= "2" >22222</OPTION>}
<option value= "3" >33333</OPTION>}
</select>

<script type= "Text/javascript" >
var getText = function () {
var sel = document.getelementsbytagname (' select ');
alert (Sel[0].options[sel[0].selectedindex].text);
var sel = document.getElementById (' se ');
alert (Sel.options[sel.selectedindex].value);
}

7. How to write the Foo () function in JS in a timed call?

 function foo () {

Alert (new Date ());

SetTimeout (' foo () ', 2000);

}

Foo ();

8, var a = ten, b =20,c = 10;alert (a = b); alert (A = = B); alert (A = = c) result?

Alert (a = b), 10

Alert (A = = B), false

Alert (A = = c)-True

The first = is an assignment statement that assigns the value A to 10,== is the comparison statement

Iv. Procedural Questions

1, complete the contents of the Foo () function, ask to be able to pop up the dialog box prompt is currently selected the first few radio boxes.
<body>
<script>
function foo () {
Add code here
var rg = document.getelementsbyname ("Radiogroup");
For (var i = 0;   i < rg.length; i++)
  {   
if (rg[i].checked)
      {   
alert ("You have selected" + (I+1) + "Radio Box");
      }   
  }   
return false;
} </script>
<body>
<form name= "Form1" onsubmit= "return foo ();" >
<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>

2, fill the comment part of the function body, so that the Foo () function call popup "Success" of the dialog box, as well as the string rollover function
<script>
function foo () {
var str = reverse (' a,b,c,d,e,f,g ');
alert (str);
if (str = = ' G,f,e,d,c,b,a ')
Alert (' success ');
Else
Alert (' failure ');
}
function reverse (str) {
Add code here to complete the string rollover function

Return Str.split (","). Reverse (). Join (",");

}
</script>
<body>
<input type= "button" value= "str" onclick= "foo ()"/>
</body>

JavaScript Complete Interview Questions

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.