[Niu Ke Brushing Questions Diary] — Javascript Clearance Cheats (3)

CSDN Topic Challenge Phase 2
Participation Topic: Interview Collection

Everyone gathers firewood and the flame is high. Let's work together to build an interview book. You can gather all kinds of interview questions in various languages, technologies, or interview questions you have brushed here. On the occasion of gold, silver, and tenth, let us help the candidates~

insert image description here

the way forward

Question 1:

Which of the following is the correct usage of array in JavaScript?

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

B:
var txt = new Array="tim","kim","jim"

C:
var txt = new Array:1=("tim")2=("kim")3=("jim")

D:
var txt = new Array(1:"tim",2:"kim",3:"jim")

Analysis of the problem:

This question is very basic, we must read it carefully and answer it carefully

Answers to questions:

  • Pass a numeric parameter to new Array(), indicating the length of the new array generated
  • Passing a non-numeric parameter to new Array() means generating a new array containing the parameter
  • Passing multiple parameters to new Array() means generating a new array containing these parameter members

Question two:

One of the following options that can get the input node is ()

<form class="file" name="upload">
    <input id="file" name="file"/>
</form>

Analysis of the problem:

  • document.querySelectorAll('file')[0] gets the element with the first tag named file, not the input tag, option A is wrong; document.getElementById(file') returns the node whose id attribute is file, instead of an array;
  • B option is wrong, D option is correct;
  • The document object has no getElementByTagName() method, and option C is wrong.

Answers to questions:

document.getElementsByName() returns a Nodelist collection of elements with the given name in the document

personal experience summary

We must make good use of Nioke, a question-writing platform, and brush a few questions every day. Of course, the most important thing is to look at our questions.Interview Collection!

Data summary/question guide

Niuke.com is a website that many programmers like. Link posted: Niu Ke

Guess you like

Origin blog.csdn.net/fsadagds/article/details/126963578