Upwork JavaScript Test 2016 >>>
88 Answered Test Questions:
1. Which of the following is true about setTimeOut()?
Answers:
a. The statement(s) it executes run(s) only once.
a. It pauses the script in which it is called.
a. clearTimeOut() won’t stop its execution.
a. The delay is measured in hundredths of a second.
a. It is required in every JavaScript function.
2. How can the operating system of the client machine be detected?
Answers:
a. It is not possible using JavaScript.
a. Using the navigator object
a. Using the window object
a. Using the document object
a. None of these.
3. Which of the following prints “AbBc”?
Answers:
a. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
a. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’c'[‘toUpperCase’](); alert(result);
a. var b = ‘a’; var result = b.toUpperCase() + b + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
a. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +C; alert(result);
4. Which of the following descriptions is true for the code below?
1. Which of the following is true about setTimeOut()?
Answers:
a. The statement(s) it executes run(s) only once.
a. It pauses the script in which it is called.
a. clearTimeOut() won’t stop its execution.
a. The delay is measured in hundredths of a second.
a. It is required in every JavaScript function.
2. How can the operating system of the client machine be detected?
Answers:
a. It is not possible using JavaScript.
a. Using the navigator object
a. Using the window object
a. Using the document object
a. None of these.
3. Which of the following prints “AbBc”?
Answers:
a. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
a. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’c'[‘toUpperCase’](); alert(result);
a. var b = ‘a’; var result = b.toUpperCase() + b + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
a. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +C; alert(result);
4. Which of the following descriptions is true for the code below?
var object0 = {};
Object.defineProperty(object0, “prop0”, { value : 1, enumerable:false, configurable : true });
Object.defineProperty(object0, “prop1”, { value : 2, enumerable:true, configurable : false });
Object.defineProperty(object0, “prop2”, { value : 3 });
object0.prop3 = 4;
Answers:
a. Object ‘object0’ contains 4 properties. Property ‘prop2’ and property ‘prop3’ are available in the for…in loop. Property ‘prop0’ and property ‘prop1’ are available to delete.
a. Object ‘object0’ contains 4 properties. Property ‘prop1’ and property ‘prop2’ are available in the for…in loop. Property ‘prop2’ and property ‘prop3’ are available to delete.
a. Object ‘object0’ contains 4 properties. Property ‘prop0’ and property ‘prop2’ are available in the for…in loop. Property ‘prop0’ and property ‘prop2’ are available to delete.
a. Object ‘object0’ contains 4 properties. Property ‘prop1’ and property ‘prop3’ are available in the for…in loop. Property ‘prop0’ and property ‘prop3’ are available to delete.
5. Performance-wise, which is the fastest way of repeating a string in JavaScript?
Answers:
a. String.prototype.repeat = function( num ) { return new Array( num + 1 ).join( this ); }
a. function repeat(pattern, count) { if (count < 1) return ”; var result = ”; while (count > 0) { if (count & 1) result += pattern; count >>= 1, pattern += pattern; } return result; }
a. String.prototype.repeat = function(count) { if (count < 1) return ”; var result = ”, pattern = this.valueOf(); while (count > 0) { if (count & 1) result += pattern; count >>= 1, pattern += pattern; } return result; };
a. String.prototype.repeat = function (n, d) { return –n ? this + (d || ”) + this.repeat(n, d) : ” + this };
6. Consider the following variable declarations:
Object.defineProperty(object0, “prop0”, { value : 1, enumerable:false, configurable : true });
Object.defineProperty(object0, “prop1”, { value : 2, enumerable:true, configurable : false });
Object.defineProperty(object0, “prop2”, { value : 3 });
object0.prop3 = 4;
Answers:
a. Object ‘object0’ contains 4 properties. Property ‘prop2’ and property ‘prop3’ are available in the for…in loop. Property ‘prop0’ and property ‘prop1’ are available to delete.
a. Object ‘object0’ contains 4 properties. Property ‘prop1’ and property ‘prop2’ are available in the for…in loop. Property ‘prop2’ and property ‘prop3’ are available to delete.
a. Object ‘object0’ contains 4 properties. Property ‘prop0’ and property ‘prop2’ are available in the for…in loop. Property ‘prop0’ and property ‘prop2’ are available to delete.
a. Object ‘object0’ contains 4 properties. Property ‘prop1’ and property ‘prop3’ are available in the for…in loop. Property ‘prop0’ and property ‘prop3’ are available to delete.
5. Performance-wise, which is the fastest way of repeating a string in JavaScript?
Answers:
a. String.prototype.repeat = function( num ) { return new Array( num + 1 ).join( this ); }
a. function repeat(pattern, count) { if (count < 1) return ”; var result = ”; while (count > 0) { if (count & 1) result += pattern; count >>= 1, pattern += pattern; } return result; }
a. String.prototype.repeat = function(count) { if (count < 1) return ”; var result = ”, pattern = this.valueOf(); while (count > 0) { if (count & 1) result += pattern; count >>= 1, pattern += pattern; } return result; };
a. String.prototype.repeat = function (n, d) { return –n ? this + (d || ”) + this.repeat(n, d) : ” + this };
6. Consider the following variable declarations:
var a=”adam”
var b=”eve”
var b=”eve”
Which of the following would return the sentence “adam and eve”?
Answers:
a. a.concatinate(“and”, b)
a. a.concat(“and”, b)
a. a.concatinate(” and “, b)
a. a.concat(” and “, b)
7. Which of the following code snippets will correctly split “str”?
Answers:
a.
a.
a.
a.
8. Which object can be used to ascertain the protocol of the current URL?
Answers:
a. document
a. window
a. history
a. browser
a. form
a. location
9. Which of the following best describes a “for” loop?
Answers:
a. “for” loop consists of six optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
a. “for” loop consists of five optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
a. “for” loop consists of four optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
a. “for” loop consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
10. Which of the following descriptions best describes the code below?
Answers:
a. a.concatinate(“and”, b)
a. a.concat(“and”, b)
a. a.concatinate(” and “, b)
a. a.concat(” and “, b)
7. Which of the following code snippets will correctly split “str”?
Answers:
a.
a.
a.
a.
8. Which object can be used to ascertain the protocol of the current URL?
Answers:
a. document
a. window
a. history
a. browser
a. form
a. location
9. Which of the following best describes a “for” loop?
Answers:
a. “for” loop consists of six optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
a. “for” loop consists of five optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
a. “for” loop consists of four optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
a. “for” loop consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
10. Which of the following descriptions best describes the code below?
Answers:
a. Object is frozen, a property named “price” is added in the variable1 object, a property named “length” is deleted from this object. At the end of the code, the object “variable1” contains 2 properties.
a. Object is frozen, a property named “price” is not added in the variable1 object, a property named “length” is deleted from this object. At the end of the code, object “variable1” contains 1 properties.
a. Object is frozen, a property named “price” is added in the variable1 object, a property named “length” is not deleted from this object. At the end of the code, object “variable1” contains 1 properties.
a. Object is frozen, a property named “price” is not added in the variable1 object, a property named “length” is not deleted from this object. At the end of the code, object “variable1” contains 2 properties.
11. Which of the following is not a valid HTML event?
Answers:
a. ondblclick
a. onmousemove
a. onclick
a. onblink
12. Analyze the following code snippet which uses a Javascript Regular Expression character set. What will be the output of this code?
s
Answers:
a. I
a. Is
a. s
a. I,s,
13. Consider the following image definition:
Which of the following will change the image to companylogo2.gif when the page loads?
Answers:
a. logo.source=”companylogo2.gif”
a. logo.source=”companylogo1.gif”
a. document.getElementById(‘logo’).src=”companylogo1.gif”
a. document.getElementById(‘logo’).src=”companylogo2.gif”
14. What is the final value of the variable bar in the following code?
Answers:
a. I
a. Is
a. s
a. I,s,
13. Consider the following image definition:
Which of the following will change the image to companylogo2.gif when the page loads?
Answers:
a. logo.source=”companylogo2.gif”
a. logo.source=”companylogo1.gif”
a. document.getElementById(‘logo’).src=”companylogo1.gif”
a. document.getElementById(‘logo’).src=”companylogo2.gif”
14. What is the final value of the variable bar in the following code?
var foo = 9;
bar = 5;
(function() {
var foo = 2;
bar= 1;
}())
bar = bar + foo;
Answers:
a. 10
a. 14
a. 3
a. 7
15. Which of the following are JavaScript unit testing tools?
Answers:
a. Buster.js, jQuery, YUI Yeti
a. QUnit, Modernizr, JsTestDriver
a. Node.js, Modernizr, Jasmine
a. Buster.js, YUI Yeti, Jasmine
16. Which of the following can be used for disabling the right click event in Internet Explorer?
Answers:
a. event.button == 2
a. event.button == 4
a. event.click == 2
a. event.click == 4
17. An image tag is defined as follows:
The purpose of the ImageChange() function is to change the image source to Image2.jpg. Which of the following should the ImageChange() function look like?
Answers:
a. document.getElementById(‘ERImage’).src=”Image1.jpg”
a. document.getElementById(‘ERImage’).src=”Image2.jpg”
a. document.getElementById(‘ERImage’).style.src=”Image1.jpg”
a. document.getElementById(‘ERImage’).style.src=”Image2.jpg”
18. Consider the following JavaScript alert:
Which of the following will run the function when a user opens the page?
Answers:
a. body onload=”message()”
a. body onunload=”message()”
a. body onsubmit=”message()”
a. body onreset=”message()”
19. Which of the following code snippets will correctly get the length of an object?
Answers:
a.
a.
a.
a.
20. Which of the following Array methods in JavaScript runs a function on every item in the Array and collects the result from previous calls, but in reverse?
Answers:
a. reduce()
a. reduceRight()
a. reverse()
a. pop()
21. In an HTML page, the form tag is defined as follows:
bar = 5;
(function() {
var foo = 2;
bar= 1;
}())
bar = bar + foo;
Answers:
a. 10
a. 14
a. 3
a. 7
15. Which of the following are JavaScript unit testing tools?
Answers:
a. Buster.js, jQuery, YUI Yeti
a. QUnit, Modernizr, JsTestDriver
a. Node.js, Modernizr, Jasmine
a. Buster.js, YUI Yeti, Jasmine
16. Which of the following can be used for disabling the right click event in Internet Explorer?
Answers:
a. event.button == 2
a. event.button == 4
a. event.click == 2
a. event.click == 4
17. An image tag is defined as follows:
The purpose of the ImageChange() function is to change the image source to Image2.jpg. Which of the following should the ImageChange() function look like?
Answers:
a. document.getElementById(‘ERImage’).src=”Image1.jpg”
a. document.getElementById(‘ERImage’).src=”Image2.jpg”
a. document.getElementById(‘ERImage’).style.src=”Image1.jpg”
a. document.getElementById(‘ERImage’).style.src=”Image2.jpg”
18. Consider the following JavaScript alert:
Which of the following will run the function when a user opens the page?
Answers:
a. body onload=”message()”
a. body onunload=”message()”
a. body onsubmit=”message()”
a. body onreset=”message()”
19. Which of the following code snippets will correctly get the length of an object?
Answers:
a.
a.
a.
a.
20. Which of the following Array methods in JavaScript runs a function on every item in the Array and collects the result from previous calls, but in reverse?
Answers:
a. reduce()
a. reduceRight()
a. reverse()
a. pop()
21. In an HTML page, the form tag is defined as follows:
No comments:
Post a Comment