Sunday, November 6, 2016

Javascript Test 2016 – Upwork Test Answers

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?
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:
var a=”adam”
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. 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?
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:
The validate() function is intended to prevent the form from being submitted if the name field in the form is empty. What should the validate() function look like?
Answers:
a.
a.a. script type=”text/javascript”> function Validate() { if(document.forms[0].name== “”) return false; else return true; }
a.
22. Which of the following code snippets changes an image on the page?
Answers:
a. var img = document.getElementById(“imageId”); img.src = “newImage.gif”;
a. var img = document.getElementById(“imageId”); img.style.src = “newImage.gif”;
a. var img = document.getElementById(“imageId”); img.src.value = “newImage.gif”;
a. var img = document.getElementById(“imageId”); img = “newImage.gif”;
23. Which of the following results is returned by the JavaScript operator “typeof” for the keyword “null”?
Answers:
a. function
a. object
a. string
a. number
24. What will be the final value of the variable “apt”?
var apt=2;
apt=apt<<2;
Answers:
a. 2
a. 4
a. 6
a. 8
a. 16
25. How can a JavaScript object be printed?
Answers:
a. console.log(obj)
a. console.print(obj)
a. console.echo(obj);
a. None of these
26. Which of the following is the correct syntax for using the JavaScript exec() object method?
Answers:
a. RegExpObject.exec()
a. RegExpObject.exec(string)
a. RegExpObject.exec(parameter1,parameter2)
a. None of these
27. Having an array object var arr = new Array(), what is the best way to add a new item to the end of an array?
Answers:
a. arr.push(“New Item”)
a. arr[arr.length] = “New Item”
a. arr.unshift(“New Item”)
a. arr.append(“New Item”)
28. Consider the following JavaScript validation function:
function ValidateField()
{
if(document.forms[0].txtId.value ==””)
{return false;}
return true;
}
Which of the following options will call the function as soon as the user leaves the field?
Answers:
a. input name=txtId type=”text” onreset=”return ValidateField()”
a. input name=txtId type=”text” onfocus=”return ValidateField()”
a. input name=txtId type=”text” onsubmit=”return ValidateField()”
a. input name=txtId type=”text” onblur=”return ValidateField()”
29. Which of following uses the “with” statement in JavaScript correctly?
Answers:
a. with (document.getElementById(“blah”).style) { background = “black”; color = “blue”; border = “1px solid green”; }
a. with document.getElementById(“blah”).style background = “black”; color = “blue”; border = “1px solid green”; End With
a. With document.getElementByName(“blah”).style background = “black”; color = “blue”; border = “1px solid green”; End With
a. with (document.getElementById(“blah”).style) { .background = “black”; .color = “blue”; .border = “1px solid green”; }
30. Consider the following JavaScript validation function:
Which of the following options will call the function as soon as the user leaves the field?
Answers:
a. input name=txtId type=”text” onreset=”return ValidateField()”
a. input name=txtId type=”text” onfocus=”return ValidateField()”
a. input name=txtId type=”text” onsubmit=”return ValidateField()”
a. input name=txtId type=”text” onblur=”return ValidateField()”
31. Which of the following modifiers must be set if the JavaScript lastIndex object property was used during pattern matching?
Answers:
a. i
a. m
a. g
a. s
32. 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”
33. Which of the following will check whether the variable vRast exists or not?
Answers:
a. if (typeof vRast=”undefined”) {}
a. if (typeof vRast ==”undefined”) {}
a. if (vRast.defined =true) {}
a. if (vRast.defined ==true) {}
34. What would be the use of the following code?
function validate(field) {
var valid=”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”;
var ok=”yes”;
var temp;
for(var i=0;i<field.value.length;i++) {
temp=”” + field.value.substring(i,i+1)
if(valid.indexOf(temp)==”-1”) {
ok=”no”;
}
}
if(ok==”no”) {
alert(”error”);
field.focus();
}
}
Answers:
a. It will force a user to enter only numeric values.
a. It will force a user to enter only alphanumeric values.
a. It will force a user to enter only English alphabet character values.
a. None of these.
35. 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”
36. Which of the following choices will detect if “variableName” declares a function?

Answers:
a. return variableName;
a. nameof variableName;
a. isFunction variableName;
a. typeof variableName;
37. Which of the following choices will change the source of the image to “image2.gif” when a user clicks on the image?
Answers:
a. img id=”imageID” src=”image1.gif” width=”50″ height=”60″ onmousedown=”changeimg(image1.gif)” onmouseup=”changeimg(image2.gif)”
a. img id=”imageID” src=”image1.gif” width=”50″ height=”60″ onmouseclick=”changeimg(image2.gif)” onmouseup=”changeimg(image1.gif)”
a. img id=”imageID” src=”image2.gif” width=”50″ height=”60″ onmousedown=”changeimg(image1.gif)” onmouseup=”changeimg(image2.gif)”
a. img id=”imageID” src=”image2.gif” width=”50″ height=”60″ onmousedown=”changeimg(image2.gif)” onmouseup=”changeimg(image1.gif)”
a. img id=”imageID” src=”image1.gif” width=”50″ height=”60″ onmousedown=”changeimg(‘image2.gif’)” onmouseup=”changeimg(‘image1.gif’)”
38. How can created cookies be deleted using JavaScript?
Answers:
a. They can’t be deleted. They are valid until they expire.
a. Overwrite with an expiry date in the past
a. Use escape() on the value of the path attribute
a. Use unescape() on the value of the path attribute
a. The cookie file will have to be removed from the client machine.
a. Wait till the expiry date is reached
39. What would be the value of ‘ind’ after execution of the following code?
var msg=”Welcome to ExpertRating”
var ind= msg.substr(3, 3)
Answers:
a. lco
a. com
a. ome
a. Welcome
40. Are the two statements below interchangeable?
object.property
object[”property”]
Answers:
a. Yes
a. No
41. Which of the following is not a valid method in generator-iterator objects in JavaScript?
Answers:
a. send()
a. throw()
a. next()
a. stop()
42. Which of the following code snippets will return all HTTP headers?
Answers:
a. var req = new XMLHttpRequest(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); alert(headers);
a. var req = new XMLHttpAccess(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); alert(headers);
a. var req = new XMLHttpRequest(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.getResponseHeader().toLowerCase(); alert(headers);
a. var req = new XMLHttpRequestHeader(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.retrieveAllResponseHeaders().toLowerCase(); alert(headers);
43. 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()”
44. Which of the following is the most secure and efficient way of declaring an array?
Answers:
a. var a = []
a. var a = new Array()
a. var a = new Array(n)
a. var a
45. Which of the following Regular Expression pattern flags is not valid?
Answers:
a. gi
a. p
a. i
a. g
46. Which of the following built-in functions is used to access form elements using their IDs?
Answers:
a. getItem(id)
a. getFormElement(id)
a. getElementById(id)
a. All of these
47. Which of the following statements is correct?
Answers:
a. There is no undefined property in JavaScript.
a. Undefined object properties can be checked using the following code: if (typeof something == null) alert(“something is undefined”);
a. It is not possible to check for undefined object properties in JavaScript.
a. Undefined object properties can be checked using the following code: if (typeof something === “undefined”) alert(“something is undefined”);
48. Which of the following correctly uses a timer with a function named rearrange()?
Answers:
a. tmr=setTimeout(“rearrange ()”,1)
a. tmr=Timer(1,”rearrange ()”)
a. tmr=Timer(“rearrange ()”,1)
a. tmr=setTimeout(1,”rearrange ()”)
49. Which of the following can be used to escape the ‘ character?
Answers:
a. *
a. \
a. –
a. @
a. #
a. %
a. |
a. ~
50. Which event can be used to validate the value in a field as soon as the user moves out of the field by pressing the tab key?
Answers:
a. onblur
a. onfocus
a. lostfocus
a. gotfocus
a. None of these
51. When setting cookies with JavaScript, what will happen to the cookies.txt data if the file exceeds the maximum size?
Answers:
a. The script automatically generates a run-time error.
a. The script automatically generates a load-time error.
a. All processes using document.cookie are ignored.
a. The file is truncated to the maximum length.
52. Which of the following are not global methods and properties in E4X?
Answers:
a. ignoreComments
a. ignoreWhiteSpace
a. setName()
a. setNamespace()
a. ignoreComments and ignoreWhiteSpace
a. setName() and setNamespace()
53. Which of the following will change the color of a paragraph’s text to blue when a user hovers over it, and reset it back to black when the user hovers out?
Answers:
a.
The text of the paragraph..
a.
The text of the paragraph..
a.
The text of the paragraph..
a.
The text of the paragraph..
a.
The text of the paragraph..
54. What is the purpose of while(1) in the following JSON response?
while(1);[[‘u’,[[‘smsSentFlag’,’false’],[‘hideInvitations’,’false’],[‘remindOnRespondedEventsOnly’,’true’],[‘hideInvitations_remindOnRespondedEventsOnly’,’false_true’],[‘Calendar ID stripped for privacy’,’false’],[‘smsVerifiedFlag’,’true’]]]]
Answers:
a. It’s invalid JSON code.
a. It makes it difficult for a third-party to insert the JSON response into an HTML document with a
Answers:
a. bar['baz']();
a. object['foo']['bar']['baz']();
a. document['foo']['bar']['baz']();
a. window['foo']['bar']['baz']();
57. Which of the following determines whether cookies are enabled in a browser or not?
Answers:
a. (navigator.Cookie)? true : false
a. (application.cookieEnabled)? true : false
a. (navigator.cookieEnabled)? true : false
a. (application.cookie)? true : false
58. Which of the following options can be used for adding direct support for XML to JavaScript?
Answers:
a. E4X
a. egex
a. Generators and Iterators
a. let
59. Which of the following will detect which DOM element has the focus?
Answers:
a. document.activeElement
a. document.ready
a. document.referrer
a. document.getelementbyid
60. Which of the following will randomly choose an element from an array named myStuff, given that the number of elements changes dynamically?
Answers:
a. randomElement = myStuff[Math.floor(Math.random() * myStuff.length)];
a. randomElement = myStuff[Math.ceil(Math.random() * myStuff.length)];
a. randomElement = myStuff[Math.random(myStuff.length)];
a. randomElement = Math.random(myStuff.length);
61. How can global variables be declared in JavaScript?
Answers:
a. All variables are local in JavaScript.
a. Declare the variable between the 'script' tags, and outside a function to make the variable global
a. Precede the variable name with the constant global
a. Declare the variable in an external file
62. Which of the following objects in JavaScript contains the collection called "plugins"?
Answers:
a. Location
a. Window
a. Screen
a. Navigator
63. What will be output of the following code?
function testGenerator() {
yield "first";
document.write("step1");
yield "second";
document.write("step2");
yield "third";
document.write("step3");
}
var g = testGenerator();
document.write(g.next());
document.write(g.next());
Answers:
a. firststep1second
a. step1step2
a. step1
a. step1step2step3
64. Which of the following methods will copy data to the Clipboard?
Answers:
a. execClipboard('Copy')
a. copyCommand('Clipboard')
a. execCommand('Copy')
a. execClipboard('Copy')
65. Which of the following code snippets trims whitespace from the beginning and end of the given string str?
Answers:
a. str.replace(/^\s+|\s+$/g, '');
a. str.replace(/^\s+/,'');
a. str.replace(/\s+$/,'');
a. str.replace(/\s+/g,' ');
66. What is the difference between call() and apply()?
Answers:
a. The call() function accepts an argument list of a function, while the apply() function accepts a single array of arguments.
a. The apply() function accepts an argument list of a function, while the call() function accepts a single array of arguments.
a. The call() function accepts an object list of a function, while the apply() function accepts a single array of an object.
a. The call() function accepts an object list of a function, while the apply() function accepts a single array of an object.
67. Which of the following code snippets is more efficient, and why?

Answers:
a. Both are equally efficient.
a. The first code is more efficient as it contains less code.
a. The first code is more efficient as it employs object caching.
a. The second code is more efficient as it employs object caching.
68. What is the meaning of obfuscation in JavaScript?
Answers:
a. Obfuscation is a keyword in JavaScript.
a. Making code unreadable using advanced algorithms.
a. Decrypting encrypted source code using advanced algorithms.
a. None of these.
69. Which of the following JavaScript Regular Expression modifiers finds one or more occurrences of a specific character in a string?
Answers:
a. ?
a. *
a. +
a. #
70. Which of the following is not a valid JavaScript operator?
Answers:
a. |
a. ===
a. %=
a. ^
71. Which of the following code snippets returns "[object object]"?
Answers:
a.
a.
a.
a.
72. Which of the following can be used to invoke an iframe from a parent page?
Answers:
a. window.frames
a. document.getElementById
a. document.getelementsbyname
a. document.getelementsbyclassname
73. Select the following function that shuffles an array?
Answers:
a. function shuffle(array) { var tmp, current, top = array.length; if(top) while(--top) { current = Math.floor(Math.random() * (top + 1)); tmp = array[current]; array[current] = array[top]; array[top] = tmp; } return array; }
a. function shuffle(array) { return array.sort(function(a,b) { return (a-b); }); }
a. function shuffle(array) { var results = new Array(); var sorted_arr = array.sort(); for (var i = 0; i < array.length - 1; i++) { if (sorted_arr[i + 1] == sorted_arr[i]) { results.push(sorted_arr[i]); } } return results; }
a. function shuffle(array) { for (var tmp, cur, top=array.length; top--;){ cur = (Math.random() * (top + 1)) << 0; tmp = array[cur]; array[cur] = array[top]; array[top] = tmp; } return array.sort(); }
74. Which of the following code snippets removes objects from an associative array?
Answers:
a. delete array["propertyName"];
a. array.propertyName.remove();
a. array.splice(index, 1);
a. array["propertyName"].remove();
75. What is the error in the statement: var charConvert = toCharCode('x');?
Answers:
a. toCharCode() is a non-existent method.
a. Nothing. The code will work fine.
a. toCharCode only accepts numbers.
a. toCharCode takes no arguments.
76. What value would JavaScript assign to an uninitialized variable?
Answers:
a. NaN
a. null
a. undefined
a. false
77. What does the following JavaScript code do?
contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}
Answers:
a. It calculates an array's length.
a. It compares 'a' and 'obj' in an array.
a. The code will cause an error.
a. It checks if an array contains 'obj'.
78. If an image is placed styled with z-index=-1 and a text paragraph is overlapped with it, which one will be displayed on top?
Answers:
a. The paragraph.
a. The image.
a. It depends on other rules.
79. Which of the following code snippets gets an image's dimensions (height & width) correctly?
Answers:
a. var img = document.getElementById('imageid'); var width = img.clientWidth; var height = img.clientHeight;
a. var img = document.getElementById('imageid'); var width = img.width; var height = img.height;
a. var img = document.getElementById('imageid'); var width = img.getAttribute('width'); var height = img.getAttribute('height');
a. var img=document.getElementById("imageid"); var width=img.offsetWidth; var height=img.offsetHeight;
80. Which of the following are correct values of variableC, and why?

Answers:
a. 6, 7, 8 and 9. The + operator is defined for arrays, and it concatenates strings, so it converts the arrays to strings.
a. 6, 15 and 9. The + operator is defined for arrays, and it concatenates numbers, so it converts the arrays to numbers.
a. 6, 8, 7 and 9. The + operator is defined for arrays, and it concatenates strings, so it converts the arrays to strings.
a. 6, 87 and 9. The + operator is not defined for arrays, and it concatenates strings, so it converts the arrays to strings.
81. The following are the samples for getting a selected value in the from a dropdown list:
Which code block is correct?
Answers:
a. var e = document.getElementById("ddlViewBy"); var strUser = e.options[e.selectedIndex].text;
a. var e = document.getElementById("ddlViewBy"); var strUser = e.options[e.selectedIndex].value;
a. var e = document.getElementByName("ddlViewBy"); var strUser = e.options[e.selectedIndex].text;
a. var e = document.getElementByName("ddlViewBy"); var strUser = e.options[e.selectedIndex].value;
82. var profits=2489.8237
Which of the following code(s) produces the following output?
output : 2489.824
Answers:
a. profits.toFixed(4)
a. profits.toFixed(3)
a. profits.formatDollar(3)
a. profits.nuberFormat(3)
83. A form contains two fields named id1 and id2. How can you copy the value of the id2 field to id1?
Answers:
a. document.forms[0].id1.value=document.forms[0].id2.value
a. document.forms[0].id2.value=document.forms[0].id1.value
a. document.id1.value=document.id2.value
a. document.id2.value=document.id1.value
84. Which of the following code snippets will toggle a div element's background color?
Change Background Color.
Answers:
a.
a.
a.
a.
85. How can the user's previously navigated page be determined using JavaScript?
Answers:
a. It is not possible in JavaScript. This can be done only through server-side scripting.
a. Using the document.referrer property
a. Using the window object
a. None of these
86. Which of the following is not a valid method for looping an array?
Answers:
a. var a= [1,2]; for (var i = 0; i < a.length; i++) { alert(a[i]); }
a. var a= [1,2]; a.forEach( function(item) { alert(item); })
a. var a= [1,2]; a.map( function(item) { alert(item); })
a. var a= [1,2]; a.loop( function(item) { alert(item); })
87. Which of the following correctly sets a class for an element?
Answers:
a. document.getElementById(elementId).className = "Someclass";
a. document.getElementById(elementId).setAttribute("className", "Someclass");
a. document.getElementById(elementId).class = "Someclass";
a. document.getElementById(elementId).style = "Someclass";
88. An HTML form contains 10 checkboxes all named "chkItems". Which JavaScript function can be used for checking all the checkboxes together?
Answers:
a. function CheckAll() { for (z = 0; z < document.forms.chkItems.length; z++) { document.forms.chkItems[z].checked=true } }
a. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems[z].checked=true } }
a. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems.list[z].checked=true } }
a. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems.list[z].checked=false } }

No comments:

Post a Comment

Earn for Free

http://hiredrmjru.trade/3670784521590/