JavaScript Basics
Test your knowledge of JavaScript fundamentals including syntax, events, functions, and web security concepts.
Questions
Which of the following is NOT a type of popup box.
- Alert
- Confirm
- Radio
- Text
The most common way to assign a value to a variable is by using what ?
- Equals sign
- Name It
- CSS
- HTML
a++; is the same as which of the following ?
- a=a+2;
- a=a+3;
- a=a+1;
- a=a+4;
To keep the browser from performing a script as soon as it is loaded you need to write the script as a what ?
- function
- delay
- performance
- Flexibility
Actions that can be detected by javascript are called ?
- HTML
- Events
- Array
- ArrayList
A variable that your webpage can store on or retrieve from the users computer is known as ?
- Applet
- Java
- Cookie
- Session
In JavaScript, capital letters are different from lowercase letters ?
- Not on windows platforms
- Yes
- No
- Not on Linux Platform
Which is detected when the mouse moves over a link ?
- overMouse event
- onMouseOver event
- onRollOver event
- OnMouseOut event
How do you read the first character in a string ?
- stringName.charAt(0);
- stringName.substring(1);
- stringName.charAt(1);
- stringName.charAt(2);
Which has no syntax error ?
- alert("hello "+3+" times);
- alert("hello "+3 times);
- alert("hello +3+ times");
- alert("hello "+3 +" times);
Which method will open a new window ?
- popUp(PageURL,WindowName,settings);
- window.launch(PageURL,WindowName,settings);
- window.close(PageURL,WindowName,settings);
- window.open(PageURL,WindowName,settings);
Which method is used to search for a substring ?
- stringVariable.substring(subString)
- stringVariable.find(subString)
- stringVariable.indexOf(subString)
- stringVariable.indexOf(charAt(0))
Inside which HTML element do we put the JavaScript?
- <scripting>
- <javascript>
- <js>
- <script>
What is the correct JavaScript syntax to write "Hello World"?
- Hello World"
- document.write("Hello World")
- response.write("Hello World")
- ("Hello World")
What is the correct syntax for referring to an external script called "xxx.js"?
- <script name="xxx.js">
- <script href="xxx.js">
- <script src="xxx.js">
- <link src="xxx.js">
Which among the below are the best defences against XSS? Select 2 answers
- Use HTTPS only cookie
- Output Encoding
- Data Validation
- Use HTTPS protocol