0

Basic JavaScript Quiz 1

Description: Basic JavaScript Quiz 1
Number of Questions: 10
Created by:
Tags: javascript
Attempted 0/10 Correct 0 Score 0

What is the correct JavaScript syntax for opening a new window called "window5" ?


Correct Option: B

AI Explanation

To answer this question, you need to understand the JavaScript syntax for opening a new window.

Let's go through each option to understand why it is correct or incorrect:

Option A) new("http://www.ex-designz.net","window5") - This option is incorrect because the new keyword is used for creating instances of objects, not for opening new windows.

Option B) window.open("http://www.ex-designz.net","window5") - This option is correct. The window.open() method is used to open a new window. The first parameter is the URL of the page to be loaded in the new window, and the second parameter is the name of the new window.

Option C) open.newwindow("http://www.ex-designz.net","window5") - This option is incorrect because the correct syntax is window.open(), not open.newwindow().

Option D) new.window("http://www.ex-designz.net","window5") - This option is incorrect because the correct syntax is window.open(), not new.window().

The correct answer is Option B) window.open("http://www.ex-designz.net","window5"). This option is correct because it uses the correct syntax for opening a new window in JavaScript.

How do you put a message in the browser's status bar?

  1. window.status = "put your message here"

  2. statusbar = "put your message here"

  3. status("put your message here")

  4. window.status("put your message here")


Correct Option: A

How do you find the client's browser name?

  1. browser.name

  2. navigator.appName

  3. client.navName


Correct Option: B

You define an array using

  1. var myarray = new Array();

  2. var myarray = array new;

  3. var new Array() = myarray;

  4. var new array = myarray;


Correct Option: A

Onclick is equivalent to which two events in sequence

  1. onmouseover and onmousedown

  2. onmousedown and onmouseout

  3. onmousedown and onmouseup

  4. onmouseup and onmouseout


Correct Option: C
Explanation:

To determine the correct answer, the user needs to understand the events associated with the onclick event in JavaScript.

The onclick event occurs when an element is clicked by the user. It is triggered when the mouse button is pressed down (onmousedown event) and then released (onmouseup event) while the cursor is still within the boundaries of the element. Therefore, the correct answer should include both onmousedown and onmouseup events in sequence.

Let's go through each option and explain why it is right or wrong:

A. onmouseover and onmousedown: This option is incorrect because it includes the onmouseover event, which is not part of the sequence for the onclick event. The onmouseover event is triggered when the mouse pointer enters the boundaries of an element, but it is not required for the onclick event to occur.

B. onmousedown and onmouseout: This option is incorrect because it includes the onmouseout event, which is not part of the sequence for the onclick event. The onmouseout event is triggered when the mouse pointer leaves the boundaries of an element, but it is not required for the onclick event to occur.

C. onmousedown and onmouseup: This option is correct. The onmousedown event is triggered when the mouse button is pressed down, and the onmouseup event is triggered when the mouse button is released. These two events occur in sequence when the onclick event is triggered.

D. onmouseup and onmouseout: This option is incorrect because it includes the onmouseout event, which is not part of the sequence for the onclick event. The onmouseout event is triggered when the mouse pointer leaves the boundaries of an element, but it is not required for the onclick event to occur.

Therefore, the correct answer is:

The Answer is: C. onmousedown and onmouseup

Whicj best describe void?

  1. A method

  2. A function

  3. An operator

  4. A statement


Correct Option: C

Which property would you use to redirect visitor to another page?

  1. window.location.href

  2. document.href

  3. java.redirect.url

  4. link.redirect.href


Correct Option: A
Explanation:

To redirect a visitor to another page using JavaScript, you can use the window.location.href property. This property sets or returns the entire URL of the current page, including the protocol, host name, path, and the file name of the current page. By assigning a new URL to this property, you can redirect the user to a new page.

Option A is correct: window.location.href

Option B is incorrect because there's no document.href property.

Option C is incorrect because there's no java.redirect.url property.

Option D is incorrect because there's no link.redirect.href property.

Therefore, the correct answer is:

The Answer is: A

Which of the following JavaScript statements use arrays?

  1. setTimeout("a["+i+"]",1000)

  2. k = a & i

  3. k = a(i)


Correct Option: A

AI Explanation

To answer this question, you need to understand how arrays are used in JavaScript.

An array is a special type of variable that can store multiple values in a single variable. It is created using square brackets [] and each value is separated by a comma.

Let's go through each option to understand which one uses arrays:

Option A) setTimeout("a["+i+"]",1000) - This option uses an array. The a variable is likely an array, and it is accessing the element at the index i using square brackets.

Option B) k = a & i - This option does not use arrays. It is using the bitwise AND operator (&) to perform a bitwise operation between variables a and i.

Option C) k = a(i) - This option does not use arrays. It is using parentheses () to call a function named a with the parameter i.

The correct answer is option A. This option uses an array to access an element at a specific index.

You are a junior web designer. Your company assigns you to work on a JavaScript project. Which of the following are the advantages of using JavaScript for form validation?

  1. Conservation of client CPU resources

  2. Increased validity of form submission

  3. Conservation of bandwidth

  4. Increase end-user satisfaction

  5. Either BCD


Correct Option: E

Your company assigns you to work on a JavaScript project. With the DATE object, which of the following allows you to call a function based on an elapsed time?

  1. setElapsedTime()

  2. Timeout()

  3. setTimeout()

  4. setTime()


Correct Option: D
- Hide questions