The questions in this first quiz on JavaScript are on the topics covered in the JavaScript Basics section of the site. The table below lists the lessons, a description of the lesson content and the the quiz question number range.
Lesson Summary
Click on a lesson in the table to go to that lesson for a refresher on the topics for that lesson.
JavaScript Basics Quiz
The quiz below tests your knowledge of the material learnt in the JavaScript Basics section of the site.
Question 1 : What do we use JavaScript for in our web pages?
- We use JavaScript for behaviour, CSS for presentation and HTML for structure.
Question 2 : Where do we place our <script></script> HTML element?
- The <code>script</code> HTML tag can be placed in either the <code>head</code> or <code>body</code> HTML tag.
Question 3 : JavaScript is a compiled language?
- JavaScript is an interpreted language which leads to faster development but slower runtimes than compiled languages.
Question 4 : What are JavaScript Constructors used for?
- We use JavaScript Constructors to create objects or use predefined objects.
Question 5 : What do we use to perform repetetive tasks?
- We use functions to perform repetetive tasks.
Question 6 : The code for a function is inserted between what symbols?
- The code for a function is inserted between { }. Opening and closing braces.
Question 7 : What category do Nan
and Infinity
come under?
- <code>Nan</code> and <code>Infinity</code> come under the Property category.
Question 8 : We create Math
objects using a Constructor?
- The <code>Math</code> object is static and as such we cannot create objects of this type.
Question 9 : What category does undefined
come under?
- <code>undefined</code> comes under the Variable category.
Question 10 : All predefined objects apart from the static Math
class have a constructor
method?
- The <code>JSON</code> object is also static and as such doesn't have a <code>constructor</code> method either.
Question 11 : What category do Boolean
and Regexp
come under?
- <code>Boolean</code> and <code>Regexp</code> come under the Constructor category.
Question 12 : Inline scripting is the most unobtrusive way to code our JavaScript?
- Inline scripting is actually the most obtrusive way to code our JavaScript as it mixes behaviour (JS) with structure (HTML), is prone to error and leads to higher maintenance.
Question 13 : Which of the following is the preferred way to use JavaScript to lower maintenance overhead?
- The preferred way to use JavaScript to lower maintenance overhead is by using external JavaScript files as changes can be made in one place.
Question 14 : What is the effective number of times we can use the Window.onload
method in a web page?
- We can use the Window.onload
method as many times as we like in a web page and whether placed in the <code>head</code> or <code>body</code> elements is irrelelevant. The 'gotcha' is that only the last read in <code>Window.onload</code> is the one used and so this method only really has one effective use.
Question 15 : We can use a combination of external JavaScript files, internal JavaScript file and inline scripting in a web page?
- We can use a combination of external JavaScript files, internal JavaScript file and inline scripting in a web page.
Question 16 : Division and Multiplication take precedence over Addition and Subtraction when performing several mathematical operations in the same statement?
- Division and Multiplication do take precedence over Addition and Subtraction when performing several mathematical operations in the same statement.
Question 17 : What symbols do we use to group mathematical operations we want performed first.?
- We use parentheses to group mathematical operations we want performed first.
Question 18 : What is the following code an example of?
aTotal += 10
- The code is an example of a mathematical shortcut.
Question 19 : Which symbol can we use to create multiple variables at the same time by delimiting the end of each variable name?
- You can create multiple variables at the same time by delimiting the end of each variable name with the comma (,) symbol.
Question 20 : Which of the following is an invalid name for a variable?
- Only letters, the dollar ($) and underscore (_) symbols are allowed as the first character of the variable name.
Question 21 : After variable creation you can store data of any type within it by using the equals symbol (=) via assignment.?
- JavaScript is not a 'strongly typed' language so after variable creation you can store data of any type within it by using the equals symbol (=) via assignment..
Question 22 : Which of the following is a valid name for a variable?
- Only letters, numbers, the dollar ($) and underscore (_) symbols are allowed when creating variable names.
Question 23 : Which special operator do we use to create Object
instances?
- We use the <code>new</code> special operator to create <code>Object</code> instances?.
Question 24 : How do we create Object
instance properties?
- We create <code>Object</code> instances through assignment.
Question 25 : What happens when we try to display an Object
instance property that doesn't exist?
- When we try to display an <code>Object</code> instance property that doesn't exist, the property is returned as <code>undefined</code>.
Question 26 : How can we get rid of unwanted properties of an Object
instance?
- We can get rid of unwanted properties of an <code>Object</code> instance using the <code>delete</code> special operator.
Question 27 : What is the following code an example of?
bString = 'isThisValid';
- <code>bString = 'isThisValid';</code> is an example of a 'string primitive'.
Question 28 : What is the disadvantage of using string literals compared to using a String
instance?
- There are no disadvantages to using string literals as JavaScript converts any strings to temporary <code>String</code> objects when a <code>String</code> method is called on the string.
Question 29 : What symbol do we use when concatenating strings together?
- We use the <code>+</code> (plus) symbol when concatenating strings together.
Question 30 : What value is alerted from the following code?
var aString = '5';
var aNumber = 5;
alert(aString + aNumber);
- The value <code>55</code> is alerted from the code as all numbers are converted to strings before concatenation takes place.
Question 31 : What is alerted from the following code?
aBoolean = new Boolean(false);
if (aBoolean) {
alert('false');
} else {
alert('true');
}
- When using a <code>Boolean</code> object any values other than <code>undefined</code> and <code>null</code> evaluate to <code>true</code> when passed to a conditional statement.
Question 32 : What is alerted from the following code?
aBoolean = false;
if (aBoolean) {
alert('false');
} else {
alert('true');
}
- When using boolean primitives the logic works as expected and the value <code>false</code> is returned.
Question 33 : What should we use for conditional statements?
- We should use boolean primitives for conditional statements and the <code>Boolean</code> constructor when we just want to wrap a boolean value.
Quiz Progress Bar Please select an answer
What's Next?
In the next quiz we test our knowledge of the topics covered in the JavaScript Intermediate section of the site .