JavaScript Flashcards
How can you add new DIV elements dynamically? Select one: a. document.createDiv( ) b. document.newElement('div') c. document.createElement('div') d. document.createNode('div')
c. document.createElement(‘div’)
The output of the go( ) function is \_\_\_\_\_ and the run( ) function is \_\_\_\_\_\_. html body button onclick="go();" Go button button onclick="run();" Run button body script type="text/javascript" dan = 'Dan Pickles'; function go(){ alert( 'Hello ' + dan); } function run(){ alert(dan);}script html Select one: a. Hello Dan Pickles, Dan Pickles b. Undefined, Undefined c. Nothing, Nothing d. Uncaught ReferenceError: dan is not defined, Uncaught ReferenceError: dan is not defined e. Hello Dan Pickles, Undefined f. Undefined, Dan Pickles
a. Hello Dan Pickles, Dan Pickles
We can add more than one ‘document.ready’ function in a page.
Select one:
a. False
b. True
b. True
What is === operator?
Select one:
a. Compares value equality as well as data type
b. Basic comparison operator
c. Basic assignment operator
d. Compares equality and, if equal, assigns the value of the left operator to the value of the right
a. Compares value equality as well as data type
What is not true about JavaScript?
Select one:
a. It is widely used for client side validation
b. JavaScript is a scripting language
c. Embedded in Netscape, Internet Explorer, and other web browsers
d. It is object-based, lightweight and cross platform
e. Able to build interactivity into otherwise static HTML pages
f. JavaScript relies on server-side technologies to manage cookies
f. JavaScript relies on server-side technologies to manage cookies
What is the output of the following code: alert( isNaN('Dan') ) Select one: a. True b. False c. Null d. Undefined
a. True
What is the output of the following code: window.onload = function a( ){ console.log(obj.prop); }
Select one:
a. None of these
b. Null
c. Undefined
d. Uncaught ReferenceError: obj is not defined
d. Uncaught ReferenceError: obj is not defined
What is the output of the following snippet assuming it is the only function in the script tag: window.onload = alert(dan);
Select one:
a. Dan
b. Undefined
c. None of the above
d. Uncaught ReferenceError: dan is not defined
d. Uncaught ReferenceError: dan is not defined
What is the output of the following snippet assuming it is the only function in the script tag: window.onload = function() {var dan; alert(dan);}
Select one:
a. Dan
b. None of the above
c. Undefined
d. Uncaught ReferenceError: dan is not defined
c. Undefined
Which code snippet will produce negative infinity?
Select one:
a. -10000000000000000000000 / -1000000000000000000000
b. 0 / -5
c. None of the above
d. -10 / 0
d. -10 / 0
Which JavaScript timer will execute repeatedly until the function is cancelled? Select one: a. clearInterval b. setTimer c. setInterval d. setTimeout
c. setInterval
Which is not a JavaScript data type? Select one: a. Object b. Null c. String d. Function e. Undeclared f. Number g. Boolean
e. Undeclared
Which is not a JavaScript event? Select one: a. onhover b. onload c. onchange d. onclick e. None of these
a. onhover
Which will submit a form using JavaScript?
Select one:
a. document.getElementById(‘myform’).submit( )
b. document.submit( )
c. All of these
d. document.myForm.submit( )
a. document.getElementById(‘myform’).submit( )
What is the issue with using: typeof bar === “object” in order to determine if bar is an object?
By putting object in quotes, you’re saying that object is a String and since this is strict equals, data type matters, unlike ==, which will first convert both variables to the same datatype before doing a comparison on the references.
Match the correct this reference for each invocation form.
Apply Form
Constructor Form
Function Form
Method Form
The Global object
The newly created object
The object that owns the invoked function
The object passed in as a parameter
The correct answer is: Apply Form. – The object passed in as a parameter., Constructor Form. – The newly created object., Function Form – The global object., Method Form – The object that owns the invoked function.
What is the difference between: document.getElementById( "logo" ); and $( "#logo" ); Select one: a. The first returns a list of elements while the second returns an element. b. The second one is faster. c. The first returns an element while the second returns a list of elements. d. There is no difference. e. The first one is faster.
e. The first one is faster.