MCQs > IT & Programming > PrototypeJS Javascript Framework MCQs > Basic PrototypeJS Javascript Framework MCQs

Basic PrototypeJS Javascript Framework MCQ

1. Which of the given examples returns "false"?

Answer

Correct Answer: "{ foo: 38 }".isJSON();

Note: This Question is unanswered, help us to find answer for this one

2. Evaluate the 4 following premises: 1. RegExp is an extension to the built-in RegExp object 2. Ir has one class method and one instance method 3. instance method is an alias of some native RegExp method 4. instance method returns string value as a result.

Answer

Correct Answer: One statement is false

Note: This Question is unanswered, help us to find answer for this one

3. To make a contribution, a developer might need to make a clone of Prototype project from:

Answer

Correct Answer: git://github.com/sstephenson/prototype.git

Note: This Question is unanswered, help us to find answer for this one

4. Select the wrong callback function of Prototype's AJAX object

Answer

Correct Answer: onError

Note: This Question is unanswered, help us to find answer for this one

5. How would you select all of the child elements of a specific element that match a CSS selector (.myclass) ?

Answer

Correct Answer: $('element').select('.myclass')

Note: This Question is unanswered, help us to find answer for this one

6. What is printed in the console from the below statement console.log("PrototypeJS".blank());

Answer

Correct Answer: false

Note: This Question is unanswered, help us to find answer for this one

7. Is it possible to add a method to class "on-the-fly" in Prototype 1.7, and if so how?

Answer

Correct Answer: Using Class#addMethods.

Note: This Question is unanswered, help us to find answer for this one

8. What is the shortcut to get a Form element value?

Answer

Correct Answer: $F('elementid')

Note: This Question is unanswered, help us to find answer for this one

9. Lets assume we are calling str.dasherize();. What should be a value of "str" to recieve "one-two-three" string as a result?

Answer

Correct Answer: "one_two_three"

Note: This Question is unanswered, help us to find answer for this one

10. After being encapsulated by Element.Methods, what object is it copied over to?

Answer

Correct Answer: The Element object.

Note: This Question is unanswered, help us to find answer for this one

11. Is it required to use Element#on exclusively?

Answer

Correct Answer: No. It is perfectly acceptable to continue using Element#observe, though it is less efficient.

Note: This Question is unanswered, help us to find answer for this one

12. If you want to create a distribution tarball in the pkg/ directory, what package would you run?

Answer

Correct Answer: rake package

Note: This Question is unanswered, help us to find answer for this one

13. Which class serves the purpose of sophisticated string interpolation?

Answer

Correct Answer: Template

Note: This Question is unanswered, help us to find answer for this one

14. Here is a snapcode: ' bmw, bugatti & luxury'.scan(/\w+/, alert); How many alert dialongs will you see after executing given snapcode?

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

15. Is there any utility to split a string into Array?

Answer

Correct Answer: Yes, it treats all whitespaces as delimiters

Note: This Question is unanswered, help us to find answer for this one

16. How would you loop over an array of elements (myArray) and set the value of each element to '1'?

Answer

Correct Answer: myArray.each(function(element){ element.value = '1'; });

Note: This Question is unanswered, help us to find answer for this one

17. -background-color'.camelize(); returns:

Answer

Correct Answer: backgroundColor

Note: This Question is unanswered, help us to find answer for this one

18. When using Element#on as opposed to Element#observe, what is different about its return value?

Answer

Correct Answer: Element#on has a #stop method which will remove excessive event handlers.

Note: This Question is unanswered, help us to find answer for this one

19. The 'onSuccess' callback for any of the Ajax method will auto-convert responses to JSON if what takes place?

Answer

Correct Answer: The Content Type header is set to application/JSON

Note: This Question is unanswered, help us to find answer for this one

20. Which class serves a purpose of creation an observer on an element that listens for a particular event, that element's descendants?

Answer

Correct Answer: Event.Handler

Note: This Question is unanswered, help us to find answer for this one

21. Class method String#gsub:

Answer

Correct Answer: Does not exist, it is an instance method

Note: This Question is unanswered, help us to find answer for this one

22. Which PrototypeJS method of functions have become a native method of functions?

Answer

Correct Answer: Function.bind

Note: This Question is unanswered, help us to find answer for this one

23. What do you use to add your own custom DOM methods?

Answer

Correct Answer: Element.addMethods

Note: This Question is unanswered, help us to find answer for this one

24. There is an object in Prototype that is informed about every Ajax request: Ajax.Responders. Is it possible to register callbacks that will fire on a state of ANY Ajax.Request?

Answer

Correct Answer: Yes, by using Ajax.Responders.register

Note: This Question is unanswered, help us to find answer for this one

25. The code: var json = transport.responseText.evalJSON(true); will check for what?

Answer

Correct Answer: Malicious user data.

Note: This Question is unanswered, help us to find answer for this one

26. How can you get a copy of the array without any null or undefined values?

Answer

Correct Answer: By calling Array#compact() method.

Note: This Question is unanswered, help us to find answer for this one

27. What object would you use in Prototype, and what are the benefits of using said object?

Answer

Correct Answer: Ajax.PeriodicalUpdater – It significantly reduces the load on your servers by reducing the number of requests.

Note: This Question is unanswered, help us to find answer for this one

28. How would you create an AJAX call to get the url '/echomyid'?

Answer

Correct Answer: new Ajax.Request('/echomyid');

Note: This Question is unanswered, help us to find answer for this one

29. Which method that is not available to convert to JSON in Prototype

Answer

Correct Answer: Element#toJSON

Note: This Question is unanswered, help us to find answer for this one

30. Using Element.Layout you can measure elements that are hidden:

Answer

Correct Answer: as long as their parents are visible.

Note: This Question is unanswered, help us to find answer for this one

31. When writing custom DOM methods, what must be placed as the first argument?

Answer

Correct Answer: The element itself.

Note: This Question is unanswered, help us to find answer for this one

32. Why is event delegation important in Prototype?

Answer

Correct Answer: It makes it possible to truncate resources to a single container.

Note: This Question is unanswered, help us to find answer for this one

33. Prototype JS framework with version 1.6.0 defines two additional class properties:

Answer

Correct Answer: subclasses and superclass

Note: This Question is unanswered, help us to find answer for this one

34. Utilities $A and $R create an array and ObjectRange object. What will be their results given the following string; $A($R('a', 'e')) ?

Answer

Correct Answer: ['a', 'b', 'c', 'd', 'e']

Note: This Question is unanswered, help us to find answer for this one

35. How would you create a new div element and insert it as the last child of the body?

Answer

Correct Answer: $$('body').first().insert(new Element('div'));

Note: This Question is unanswered, help us to find answer for this one

36. Why would it be beneficial to use an array in Prototype?

Answer

Correct Answer: By using an array, Prototype has extended the number of usable methods.

Note: This Question is unanswered, help us to find answer for this one

37. What is the subclass of Ajax.Request, if any?

Answer

Correct Answer: Ajax.Updater

Note: This Question is unanswered, help us to find answer for this one

38. Despite DOM elements having Prototype extensions built-in, will they function in Internet Explorer?

Answer

Correct Answer: No.

Note: This Question is unanswered, help us to find answer for this one

39. $w is responsible for?

Answer

Correct Answer: Splitting a string into an array.

Note: This Question is unanswered, help us to find answer for this one

40. DOM methods are mostly encapsulated by what object?

Answer

Correct Answer: Element.Methods

Note: This Question is unanswered, help us to find answer for this one

41. To use JSON with AJAX, what must be invoked on the transport's responseText property?

Answer

Correct Answer: String#evalJSON

Note: This Question is unanswered, help us to find answer for this one

42. What property stores the active Ajax requests?

Answer

Correct Answer: Ajax.activeRequestCount

Note: This Question is unanswered, help us to find answer for this one

43. Which callback takes precedence: on<HTTP RESPONSE CODE>, onFailure, or onSuccess?

Answer

Correct Answer: on<HTTP RESPONSE CODE>

Note: This Question is unanswered, help us to find answer for this one

44. Method "on()" of Event class can be used to set up event handlers, with or without event delegation. What is not true about Event.on?

Answer

Correct Answer: Has inner iterator

Note: This Question is unanswered, help us to find answer for this one

45. What is the right syntax of using Element#observe for the click event?

Answer

Correct Answer: $("element").observe("click", this.clickHandler);

Note: This Question is unanswered, help us to find answer for this one

46. How can you create an instance of class Storage which has one parameter in constructor?

Answer

Correct Answer: var inst = new Storage("warehouse"');

Note: This Question is unanswered, help us to find answer for this one

47. If you wanted to make Prototype extensions functional in Internet Explorer, what would you use?

Answer

Correct Answer: Element.extend()

Note: This Question is unanswered, help us to find answer for this one

48. Evaluate the following statement: Function class is an extension of a built-in Function object and has no class methods of its own.

Answer

Correct Answer: Correct

Note: This Question is unanswered, help us to find answer for this one

49. "data-my-element-info-t".camelize() returns what?

Answer

Correct Answer: dataMyElementInfoT

Note: This Question is unanswered, help us to find answer for this one

50. Prototype 1.6 introduced Element.Layout, which can be used for retrieving element measurements

Answer

Correct Answer: The first statement is incorrect, right version of introduction is 1.7. Second statement is correct for 1.7

Note: This Question is unanswered, help us to find answer for this one

51. How to receive width of an element with id='div1' in pixels?

Answer

Correct Answer: by using $('div1').offsetWidth; or by using $('div1').getStyle('width');

Note: This Question is unanswered, help us to find answer for this one

52. How to create (define) a class with the name Storage in Prototype Javascript framework?

Answer

Correct Answer: var Storage = Class.create();

Note: This Question is unanswered, help us to find answer for this one

53. Which four utilities does Prototype use?

Answer

Correct Answer: $A $w $H $R

Note: This Question is unanswered, help us to find answer for this one

54. How would you remove a class named 'removeclass' from an element?

Answer

Correct Answer: $('element').removeClassName('removeclass');

Note: This Question is unanswered, help us to find answer for this one

55. What object is used to parse JSON?

Answer

Correct Answer: String#evalJSON

Note: This Question is unanswered, help us to find answer for this one

56. (42).toPaddedString(4) returns what?

Answer

Correct Answer: 0042

Note: This Question is unanswered, help us to find answer for this one

57. Evaluate the following statement: Hash is a set of key/value pairs with Element.Layout subclass. For convenience a developer can use #H() alias.

Answer

Correct Answer: Correct

Note: This Question is unanswered, help us to find answer for this one

58. The actual Ajax requests are made by creating instances of

Answer

Correct Answer: Ajax.Request object

Note: This Question is unanswered, help us to find answer for this one

59. You have a class that inherits from a parent class. How do you call a parent version of a class method from within a child class method of the same name?

Answer

Correct Answer: function($super){ $super() }

Note: This Question is unanswered, help us to find answer for this one

60. What is the alternative of Element.extend() function in Prototype?

Answer

Correct Answer: The dollar function $()

Note: This Question is unanswered, help us to find answer for this one

61. If your data is not an instance of an object and you invoke the toJSON method, where should the syntax: toJSON() be located in the string?

Answer

Correct Answer: At the end.

Note: This Question is unanswered, help us to find answer for this one

62. When using data from an untrusted source, it should be sanitized. What does this entail?

Answer

Correct Answer: Removing malicious data from user input.

Note: This Question is unanswered, help us to find answer for this one

63. By using the Element#on object in Prototype event API, what benefit is being gained?

Answer

Correct Answer: Concisely written code and event delegation from within a container.

Note: This Question is unanswered, help us to find answer for this one

64. Element#measure(property) gives:

Answer

Correct Answer: pixel value of an element's dimension specified by property

Note: This Question is unanswered, help us to find answer for this one

65. Lets say you have an array with name myArray. How would you organize a loop?

Answer

Correct Answer: Using "for" statement or Array#each iterator.

Note: This Question is unanswered, help us to find answer for this one

66. What solution has Prototype 1.7 introduced to provide a more concise API?

Answer

Correct Answer: Element.Layout

Note: This Question is unanswered, help us to find answer for this one

67. How would you wait for the DOM to be loaded so that you can start manipulating the page with Javascript?

Answer

Correct Answer: document.observe('dom:loaded',function(){ //code here });

Note: This Question is unanswered, help us to find answer for this one

68. Which of the following is not an example of an AJAX callback?

Answer

Correct Answer: onInteractive

Note: This Question is unanswered, help us to find answer for this one

69. How can you inherit from a Storage class?

Answer

Correct Answer: After defining a descendant using Class.create() method, inherit from class Storage by using Object.extend() method.

Note: This Question is unanswered, help us to find answer for this one

70. After editing your browser script to work with Prototype extensions, what coding can you add to the end to make it function more solidly?

Answer

Correct Answer: Element.extend(my_div)

Note: This Question is unanswered, help us to find answer for this one

71. What object is informed about every AJAX request?

Answer

Correct Answer: Ajax.Responders

Note: This Question is unanswered, help us to find answer for this one

72. Instance method String#evalJSON():

Answer

Correct Answer: Evaluates the string as JSON and returns the resulting object

Note: This Question is unanswered, help us to find answer for this one

73. Do Element.Layout#get and Element#measure work together?

Answer

Correct Answer: Yes.

Note: This Question is unanswered, help us to find answer for this one

74. Select the wrong JavaScript-related MIME-types that handled by Prototype

Answer

Correct Answer: application/ext-javascript

Note: This Question is unanswered, help us to find answer for this one

75. If you wanted to extend all elements with an additional method to do 'foo' and you have already created the method foo() how would you add it?

Answer

Correct Answer: Element.addMethods({'foo' : foo});

Note: This Question is unanswered, help us to find answer for this one

76. Internet Explorer doesn't allow the extension of what onto NodeList.prototype?

Answer

Correct Answer: Enumerable

Note: This Question is unanswered, help us to find answer for this one

77. To make a contribution of patches or tests to prototypejs.org, you may NOT need:

Answer

Correct Answer: Gnu Linux distributive installed on the machine you are working on

Note: This Question is unanswered, help us to find answer for this one

78. Instance method String#extractScripts():

Answer

Correct Answer: Extracts the content of any <script> blocks present in the html page and returns them as an array of strings.

Note: This Question is unanswered, help us to find answer for this one

79. If you want to create a hash, which utility would you use?

Answer

Correct Answer: $H()

Note: This Question is unanswered, help us to find answer for this one

80. The IE properties, offsetWidth and clientHeight along with computed CSS are able to measure elements. Why not use them?

Answer

Correct Answer: IE properties struggle with “offset” vs. “client” dimensions, and CSS units need to be converted to be compatible.

Note: This Question is unanswered, help us to find answer for this one

81. Which of these is NOT a namespace in PrototypeJS? Event Abstract Number Ajax Enumerable Class Hash

Answer

Correct Answer: All of these are namespaces in PrototypeJS

Note: This Question is unanswered, help us to find answer for this one

82. What is JSON's meaning and purpose?

Answer

Correct Answer: JavaScript Object Notation, and JSON is a lightweight data-interchange format.

Note: This Question is unanswered, help us to find answer for this one

83. The dollar sign method $() returns what?

Answer

Correct Answer: An DOM element that matches the id passed extended with Prototype methods

Note: This Question is unanswered, help us to find answer for this one

84. DOM is an acronym for?

Answer

Correct Answer: Document Object Model

Note: This Question is unanswered, help us to find answer for this one

85. What is the correct syntax for a string of key-value pairs?

Answer

Correct Answer: company=example&limit=12

Note: This Question is unanswered, help us to find answer for this one

86. How can you get access to the DOM element using Prototype?

Answer

Correct Answer: $(id) or $(element), where id is a string and element is an Element itself.

Note: This Question is unanswered, help us to find answer for this one

87. Which code segment has been written using Element#on?

Answer

Correct Answer: $("messages").on("click", "a.comment_link", function(event, element) {

Note: This Question is unanswered, help us to find answer for this one

88. What is the result of having the prototype of the native browser objects extended?

Answer

Correct Answer: All DOM elements have Prototype extensions built-in.

Note: This Question is unanswered, help us to find answer for this one

89. Prototype.K(43560) returns what?

Answer

Correct Answer: 43560

Note: This Question is unanswered, help us to find answer for this one

90. Which of the following is not a targeted platform for development?

Answer

Correct Answer: Netscape Navigator

Note: This Question is unanswered, help us to find answer for this one

91. Date class is an extension to the built-in Date object and has two instance methods:

Answer

Correct Answer: Correct

Note: This Question is unanswered, help us to find answer for this one

92. Prototype is considered what kind of framework?

Answer

Correct Answer: A JavaScript framework for developing dynamic web applications.

Note: This Question is unanswered, help us to find answer for this one