JAVASCRIPT STUDY QUESTIONS
WITH ALL CORRECT ANSWERS
What is the DOM? - Answer-Document Object Model
What is AJAX? - Answer-Asynchronous JavaScript And XML
Is JavaScript case sensitive? - Answer-Yes
How do statements end in JavaScript? - Answer-With a semicolon ";"
How do you create a single line comment in JavaScript? - Answer-With two forward
slashes "//"
How do you create a multi-line comment in JavaScript? - Answer-Start with a forward
slash and asterisk, and then end with an asterisk and forward slash. "/*" "*/"
What are the valid characters for an identifier in JavaScript? - Answer-Letters, Numbers,
Underscores, and Dollar Signs
How do you denote a string in JavaScript - Answer-With either single or double quotes
surrounding the data
What is the string escape sequence to start a new line in JavaScript? - Answer-\n
Calling an external javascript file syntax? - Answer-<script type="text/javascript"
src="javascript.js"> </script>
Is javascript case sensitive? - Answer-yes!
Javascript comment syntax? - Answer-/**/ for multiple lines
// for a single line
If a variable is not a function and does not have var then it is? - Answer-a global
variable
Can variables include other variables? - Answer-yes
x=x+y is the same as what? or x=x/y? - Answer-x+=y or x/=y
,numbers + strings =?
5+"5" = ? - Answer-strings
55
javascript starts counting on what? - Answer-0
numerical comparison operators? - Answer-x==y [x is equal to y]
x===y [x is exactly equal to y]
!= [not equal to]
> [greater than]
< [less than]
>= [greater than or equal to]
<= [less than or equal to]
logical operators? - Answer-&& [and]
|| [or]
! [not]
? ternary operator
conditional variable syntax? - Answer-z=(x==y)?5:6
z = 5 if x=y;
z = 6 if x!=y;
else if conditional syntax? - Answer-if(condition)
{
code
}
else if(condition)
{
code
}
switch statement syntax? - Answer-switch(variable)
{
case 1;
code
break;
case "example";
code
break
default;
code
}
,alert box syntax? - Answer-alert("message");
confirm box syntax? - Answer-r=confirm("press a button")
if(r==true)
{
alert('you pressed ok!');
}
else
{
alert('you pressed cancel');
}
prompt box syntax? - Answer-x="prompt("text here","default value");
if(x!="null" && x!="")
{
alert("hello "+x+" how are you today?")
}
syntax for line breaks in an alert box? - Answer-'/n' + " here"
function syntax and purpose? - Answer-function functionName(var1,var2,..,var99)
{
some code
}
functions allows scripts to be executed when called.
return statement syntax? - Answer-function product(a,b)
{
return a*b;
}
alert(product(4,3)) <-- will alert 12
return function gives a value back based on function variables.
javascript syntax for a (limited loop based on specifications) syntax? - Answer-
for(variable=startvalue;variable<=endvalue;variable=variable+increment)
{
code to be run until loop is complete.
}
The while loop (a loop executed when a specific condition is met) syntax? - Answer-
while(variable<=endvalue)
{
code to be executed
}
the break and continue statement? - Answer-if(i==3)
, {
break;
}
breaks loop
if(i==3)
{
continue;
}
breaks loop and restarts at next value;
for... in statement syntax? - Answer-var person={fname:"john",lname:"doe",age:"25"};
var x;
for (x in person)
{
document.write(person[x]+" ");
}
-------
loops through all variables attached to person;
HTML DOM mouse events? - Answer-onclick
ondblclick
mousedown
mousemove
mouseover
mouseout
mouseup
onsubmit should be used for what and where? - Answer-validating form fields
ex. <form action="blah.asp" method="post" onsubmit="return checkForm()">
special text insertions? - Answer-\' single quote
\" double quote
\n new line
\r carriage return
\t tab
\b backspace
\f form feed
properties of methods defined? - Answer-properties - are values associated with an
object i.e. length
methods - are actions (functions) that can be performed on objects ie toUpperCase [an
uppercase method]
WITH ALL CORRECT ANSWERS
What is the DOM? - Answer-Document Object Model
What is AJAX? - Answer-Asynchronous JavaScript And XML
Is JavaScript case sensitive? - Answer-Yes
How do statements end in JavaScript? - Answer-With a semicolon ";"
How do you create a single line comment in JavaScript? - Answer-With two forward
slashes "//"
How do you create a multi-line comment in JavaScript? - Answer-Start with a forward
slash and asterisk, and then end with an asterisk and forward slash. "/*" "*/"
What are the valid characters for an identifier in JavaScript? - Answer-Letters, Numbers,
Underscores, and Dollar Signs
How do you denote a string in JavaScript - Answer-With either single or double quotes
surrounding the data
What is the string escape sequence to start a new line in JavaScript? - Answer-\n
Calling an external javascript file syntax? - Answer-<script type="text/javascript"
src="javascript.js"> </script>
Is javascript case sensitive? - Answer-yes!
Javascript comment syntax? - Answer-/**/ for multiple lines
// for a single line
If a variable is not a function and does not have var then it is? - Answer-a global
variable
Can variables include other variables? - Answer-yes
x=x+y is the same as what? or x=x/y? - Answer-x+=y or x/=y
,numbers + strings =?
5+"5" = ? - Answer-strings
55
javascript starts counting on what? - Answer-0
numerical comparison operators? - Answer-x==y [x is equal to y]
x===y [x is exactly equal to y]
!= [not equal to]
> [greater than]
< [less than]
>= [greater than or equal to]
<= [less than or equal to]
logical operators? - Answer-&& [and]
|| [or]
! [not]
? ternary operator
conditional variable syntax? - Answer-z=(x==y)?5:6
z = 5 if x=y;
z = 6 if x!=y;
else if conditional syntax? - Answer-if(condition)
{
code
}
else if(condition)
{
code
}
switch statement syntax? - Answer-switch(variable)
{
case 1;
code
break;
case "example";
code
break
default;
code
}
,alert box syntax? - Answer-alert("message");
confirm box syntax? - Answer-r=confirm("press a button")
if(r==true)
{
alert('you pressed ok!');
}
else
{
alert('you pressed cancel');
}
prompt box syntax? - Answer-x="prompt("text here","default value");
if(x!="null" && x!="")
{
alert("hello "+x+" how are you today?")
}
syntax for line breaks in an alert box? - Answer-'/n' + " here"
function syntax and purpose? - Answer-function functionName(var1,var2,..,var99)
{
some code
}
functions allows scripts to be executed when called.
return statement syntax? - Answer-function product(a,b)
{
return a*b;
}
alert(product(4,3)) <-- will alert 12
return function gives a value back based on function variables.
javascript syntax for a (limited loop based on specifications) syntax? - Answer-
for(variable=startvalue;variable<=endvalue;variable=variable+increment)
{
code to be run until loop is complete.
}
The while loop (a loop executed when a specific condition is met) syntax? - Answer-
while(variable<=endvalue)
{
code to be executed
}
the break and continue statement? - Answer-if(i==3)
, {
break;
}
breaks loop
if(i==3)
{
continue;
}
breaks loop and restarts at next value;
for... in statement syntax? - Answer-var person={fname:"john",lname:"doe",age:"25"};
var x;
for (x in person)
{
document.write(person[x]+" ");
}
-------
loops through all variables attached to person;
HTML DOM mouse events? - Answer-onclick
ondblclick
mousedown
mousemove
mouseover
mouseout
mouseup
onsubmit should be used for what and where? - Answer-validating form fields
ex. <form action="blah.asp" method="post" onsubmit="return checkForm()">
special text insertions? - Answer-\' single quote
\" double quote
\n new line
\r carriage return
\t tab
\b backspace
\f form feed
properties of methods defined? - Answer-properties - are values associated with an
object i.e. length
methods - are actions (functions) that can be performed on objects ie toUpperCase [an
uppercase method]