Sort out some front-end primary interview questions

1. How can I make the text start with a capital letter?

text-transform:capitalize

 2. How to generate a list of items with squares?

list-style-type:square

 3. What is the correct syntax for referencing an external script named "xxx.js"?

<script src="xxx.js">

 4. What is the correct way to define a JavaScript array?

var txt = new Array("tim", "kim", "jim")

 5. How to find the largest number between 2 and 4?

  Math.max(2, 4)

 

6. What is the JavaScript syntax to open a new window named "window2"?

window.open("http://www.w3schools.com", "window2")

 7. How to put a message in the browser's status bar?

window.status = "put your message here"

 8. What is the result of running the following code?

<body>
    <script language="JavaScript">
        document.writeln("The document was last modified on" + document.lastModified);
        var lastModObj = new Date (document.lastModified);
        alert(lastModObj.getMinutes());
    </script>
</body>

   The result of the operation is: Display the time when the document was last modified in the document

 

9. Analyze the result of running the following code.

<script language="JavaScript">
    with(document)
    {
        writeln("Last Modified Time: " + document.lastModified + "<br>");
        writeln("标题:" + document.title + "<br>");
        writeln("URL:" + document.URL + "<br>");
    }
</script>

   The title of the output text, the last modification time, and the current URL.

 

10. Analyze the result of running the following program.

<script language="JavaScript">
    var str="string"
    with(document)
    {
        writeln("<b>您好,</b>");
        writeln("Welcome to this page!" + "<br>");
        writeln("<p><b>between js tags,");
        writeln("str + "can write here</b></p>);
    }
</script>

   Running result: After the sixth line of output characters, it will wrap

 

11.

<a href="javascript:history.back()"></a>

   The code acts as the back button

<a href="javascript:history.forward()"></a>

   The code acts as a forward button

 

12. Normally, the format of a URL is: protocol//host:port/pathname? search condition

 

13. The href attribute of the location object can get the current path, change the current path, and refresh the page.

 

14. In the form, the name attribute returns the name of the form, the action attribute returns/sets the submission address of the form, the length attribute returns the number of elements contained in the form, and the target attribute sets the object to which the form is submitted.
 

15. Which of the following statements is incorrect (c)

  a.document: The topmost node to which all other nodes are attached.

  b.documentTypeDTD: The object representation of the reference (using <!DOCTYPE> syntax).

  c.Attr: represents a pair of attribute name and attribute value. This node type can contain child nodes.

  d.documentFragment: can save other nodes like document.

 

16. Which of the following is not a method of accessing a specified node is (a)

  a.  obj.value

  b.  getElementByTagName

  c.  getElementByName

  d.  getElementById

 

17. Analyze the following code:

function msg()
{
    var p = document.createElement("p");
    var Text = document.createTextNode("Hello!");
    p.appendChild("Text");
    document.body.appendChild(p);
}

   What this code does is create a new stage

 

18. The incorrect analysis of the following code is (d)

var reg = / .o./ g; //Look for a three-character string consisting of the character o followed by any character
var str = "How are you?";  //源串
var result = new Array(); // used to receive the result
while(reg.exec(str)! = null) //Execute the matching operation, if a match is found, continue to find the next item
{
    result.push(RegExp.lastMatch); //Add result
}
alert(result);

  a. The first line of the code is to find three strings consisting of the character o followed by any character.

  b. The fourth line of the code is to perform the matching operation. If a match is found, continue to find the next item.

  c. The sixth line of code is to add the result to the array.

  d. The final output is "How are you?".

 

19. Pop up the input box, the default content is "Hello World" What is the correct JavaScript syntax?

prompt("输入", "Hello World");

 20. JS features do not include (d)

  a. Explanatory.

  b. For clients.

  c. Object-based.

  d. Object-oriented.

 

21. JS Statement

var a1 = 10;
var a2 = 20;
alert("a1+a2 = " + a1 + a2)

   The result that will be displayed is: a1+a2 = 1020

 

22. The way to change all the letters in the string s to lowercase is

s.toLowerCase()

 

23. The expression generates a random integer between 0 and 7 (including 0,7)

Math.floor(Math.random()*8)

 

24. If you want to dynamically change the title of the web page after the web page is displayed, pass

document.title = ("New title content");

 

25. There is a form object in a web page, its name is mainForm, the first element of the form object is a button, its name is myButton, the method of expressing the button object is:

document.mainForm.myButton;

 

26. When using JavaScript to implement the function of the province and city cascading menu, the code to clear the original drop-down selection before adding the city list is:

document.myform.selCity.options.length = 0;

 

27. The first mark of the HTML form is the parameter method of the <form></form> tag, which indicates the method of sending the form. The parameter of the method attribute can be get or post. The data passed by the post method is invisible to the client.

 

28. To change the background color of the page document in JavaScript, you need to modify the BackgroundColor property of the document object.

 

29. In an HTML page, a form element that cannot be associated with an onChange event handler cannot have a button.

 

30 In JavaScript, you can use the getDate method of the Date object to return each day of the month.

 

31. If the following code is included in the HTML page, the correct code to write a JavaScript function to judge whether the Enter key on the keyboard is pressed is:

 

function myKeyDown(){
    if(event.keyCode == 13)
        alert("You pressed enter");
}
 

 

32. Include the following hyperlinks in the HTML document. To realize that when the mouse moves into the hyperlink, the hyperlink text becomes 30px, and the correct encoding is:

 

<a href="#" onmouseover="this.style.fontSize=30px">注册</a>
 

 

33. The following statement to create a layer is included on the HTML page, then write a JavaScript statement to display the statement of the layer, the error is (d)

 

<html>
    <body>
        <div id = "imageLayer" style="display:none;">
        <img src="image/Sunset.jpg" width="200" height="100"></div>
    </body>
</html>
  a.  document.getElementByTagName("div")[0].style.display = "block"

 

  b.  document.getElementById("imageLayer").style.display = "block"

  c.  document.getElementByName("imageLayer")[0].style.display = "block"

  d.  document.getElementByName("imageLayer").get(0).style.display = "block"

 

34. To get the value of a form element whose ID is username, the incorrect code is (a)

  a. document.username.value

  b. document.all.username.value

  c. document.getElementById("username").value

  d. If there is no form outside the form element, you can use username.value directly

 

35. If you want to control a layer named menuBar to move 20 pixels to the right, the implementation code is:

document.all.menuBar.style.pixeILeft += 20;

 

36. Web page element overflow refers to whether the redundant content is displayed when the content of the web page element overflows.

 

37. The stacking order of elements in the web page can be realized by using the CSS attribute z-index. The larger the value of the attribute, the higher the level of placement, and the value of the attribute can be a negative integer.

 

38 To evaluate the value of an expression, the functions that can be used are: eval().

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326988222&siteId=291194637