JavaScript Basics

Test your knowledge of JavaScript fundamentals including syntax, events, functions, and web security concepts.

16 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following is NOT a type of popup box.

  1. Alert
  2. Confirm
  3. Radio
  4. Text
Question 2 Multiple Choice (Single Answer)

The most common way to assign a value to a variable is by using what ?

  1. Equals sign
  2. Name It
  3. CSS
  4. HTML
Question 3 Multiple Choice (Single Answer)

a++; is the same as which of the following ?

  1. a=a+2;
  2. a=a+3;
  3. a=a+1;
  4. a=a+4;
Question 4 Multiple Choice (Single Answer)

To keep the browser from performing a script as soon as it is loaded you need to write the script as a what ?

  1. function
  2. delay
  3. performance
  4. Flexibility
Question 5 Multiple Choice (Single Answer)

Actions that can be detected by javascript are called ?

  1. HTML
  2. Events
  3. Array
  4. ArrayList
Question 6 Multiple Choice (Single Answer)

A variable that your webpage can store on or retrieve from the users computer is known as ?

  1. Applet
  2. Java
  3. Cookie
  4. Session
Question 7 Multiple Choice (Single Answer)

In JavaScript, capital letters are different from lowercase letters ?

  1. Not on windows platforms
  2. Yes
  3. No
  4. Not on Linux Platform
Question 8 Multiple Choice (Single Answer)

Which is detected when the mouse moves over a link ?

  1. overMouse event
  2. onMouseOver event
  3. onRollOver event
  4. OnMouseOut event
Question 9 Multiple Choice (Single Answer)

How do you read the first character in a string ?

  1. stringName.charAt(0);
  2. stringName.substring(1);
  3. stringName.charAt(1);
  4. stringName.charAt(2);
Question 10 Multiple Choice (Single Answer)

Which has no syntax error ?

  1. alert("hello "+3+" times);
  2. alert("hello "+3 times);
  3. alert("hello +3+ times");
  4. alert("hello "+3 +" times);
Question 11 Multiple Choice (Single Answer)

Which method will open a new window ?

  1. popUp(PageURL,WindowName,settings);
  2. window.launch(PageURL,WindowName,settings);
  3. window.close(PageURL,WindowName,settings);
  4. window.open(PageURL,WindowName,settings);
Question 12 Multiple Choice (Single Answer)

Which method is used to search for a substring ?

  1. stringVariable.substring(subString)
  2. stringVariable.find(subString)
  3. stringVariable.indexOf(subString)
  4. stringVariable.indexOf(charAt(0))
Question 13 Multiple Choice (Single Answer)

Inside which HTML element do we put the JavaScript?

  1. <scripting>
  2. <javascript>
  3. <js>
  4. <script>
Question 14 Multiple Choice (Single Answer)

What is the correct JavaScript syntax to write "Hello World"?

  1. Hello World"
  2. document.write("Hello World")
  3. response.write("Hello World")
  4. ("Hello World")
Question 15 Multiple Choice (Single Answer)

What is the correct syntax for referring to an external script called "xxx.js"?

  1. <script name="xxx.js">
  2. <script href="xxx.js">
  3. <script src="xxx.js">
  4. <link src="xxx.js">
Question 16 Multiple Choice (Multiple Answers)

Which among the below are the best defences against XSS? Select 2 answers

  1. Use HTTPS only cookie
  2. Output Encoding
  3. Data Validation
  4. Use HTTPS protocol