Test answers for PrototypeJS
Javascript Framework 2015
Elance • IT &
Programming
1. What is the correct syntax for a string of
key-value pairs?
Answers:
•
company=example&limit=12
•
example&limit=12company=
• company=limit=12
• &limit=12
2. 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?
Answers:
• It works just like
Event.observe
• It calls Event.Handler#start
• Has inner
iterator
3. In the context of Prototype, “safe” means that AJAX will function how?
Answers:
• Inter-browser.
• Cross-browser
• On no browser at all.
• On a single browser.
4. Prototype.K(43560) returns what?
Answers:
• 1
• 250
• 5
• 43560
5. Which of the following is not a targeted platform for development?
Answers:
• Apple Safari
• Netscape
Navigator
• Microsoft Internet Explorer
• Mozilla Firefox
6. The dollar sign method $() returns what?
Answers:
• An document element that
matches the id passed
• Boolean true
• A list of DOM elements that
match the CSS selector passed
• An DOM element
that matches the id passed extended with Prototype methods
• Nothing
7. If you want to create a hash, which utility would you use?
Answers:
• $H()
• $Z()
• $F()
• $Q()
8. DOM is an acronym for?
Answers:
• Document Order Maintenance
• Document Object
Model
• Document Oriented Model
• Direct Object Management
9. Prototype is considered what kind of framework?
Answers:
• An HTML framework.
• A network framework.
• A programming framework.
• A JavaScript
framework for developing dynamic web applications.
10. What is JSON's meaning and purpose?
Answers:
• JavaJava Orbit Notation, and
JSON is a lightweight data-conversion format.
• JavaScript Order Notion, and
JSON is a lightweight data-interchange format.
• JavaScript Oblique Nation, and
JSON is a lightweight data-interchange function.
• JavaScript
Object Notation, and JSON is a lightweight data-interchange format.
11. How can you inherit from a Storage class?
Answers:
• var Descendant = new
Class(Storage, { newmethod: function() { } });
• After defining
a descendant using Class.create() method, inherit from class Storage by using
Object.extend() method.
• There is no class-inheritance
in the Prototype javascript framework.
• After defining a Descendant
using Class.create() method, inherit from class Storage by calling
Descendant.inherits() method.
12. How can you get access to the DOM element using Prototype?
Answers:
• $(id), where id is a string.
• $(element) where element is an
Element itself.
• $$(id) where id is a string.
• $(id) or
$(element), where id is a string and element is an Element itself.
13. Which of the following is not an example of an AJAX callback?
Answers:
• onException
• onSuccess
• onInteractive
• onComplete
14. Which of these is NOT a namespace in PrototypeJS? Event Abstract Number Ajax Enumerable Class Hash
Answers:
• Hash
• Number
• Class
• All of these
are namespaces in PrototypeJS
• Abstract
15. Which code segment has been written using Element#on?
Answers:
•
$("messages").on("click", "a.comment_link",
function(event, element) {
• $$('#items li').each(
function(item) {
•
$("messages").observe("click", function(event) {
•
$("messages").stopObserving("click", this.clickHandler);
16. Date class is an extension to the built-in Date object and has two instance methods:
Answers:
• Correct. In addition to the
given statement it has one class method.
• The second statement is
incorrect
• Correct
• The first statement is
incorrect
17. What is the value of t at the end of this code snippet? var t = 1; $R(0,100,true).each(function(){ t++; }); console.log(t);
Answers:
• 101
• true
• None of these
• 1
• 100
18. By using the Element#on object in Prototype event API, what benefit is being gained?
Answers:
• Negligible written code and
object delegation from within a container.
• Concisely
written code and event delegation from within a container.
• Obtusely written code and event
delegation from within an object.
• Concisely written code and
event delegation from outside a container.
19. Element#measure(property) gives:
Answers:
• pixel value of
an element's dimension specified by property
• value(not only in pixels) of
the screen dimension specified by property
• nothing because it does not
exist
• pixel value of the screen
dimension specified by property
20. Do Element.Layout#get and Element#measure work together?
Answers:
• No.
• Not currently, but in the next
version of Prototype.
• Yes.
• Only in the previous version of
Prototype.
21. Instance method String#extractScripts():
Answers:
• It evaluates the scripts
• Extracts the
content of any <script> blocks present in the html page and
returns them as an array of strings.
• Extracts the content of
any <script> blocks present in the html page and returns them
as a string.
• Returns boolean
22. How to create (define) a class with the name Storage in Prototype Javascript framework?
Answers:
• var Storage = new Object();
• var Storage = Class.extend({
init: function(item){ this.item = item; }, doSomething: function() { } });
• className = function() {};
Storage = new className();
• var Storage =
Class.create();
23. Which namespace is not typically used directly but mixed in to other namespaces?
Answers:
• Enumerable
• String
• Template
• Number
• Array
24. Evaluate the following statement: Hash is a set of key/value pairs with Element.Layout subclass. For convenience a developer can use #H() alias.
Answers:
• More than one statements are
incorrect.
• Correct
• One statement is incorrect.
• Hash is a set of key/value
pairs, has Element.Layout subclass but there is no aliases defined for Hash in
Prototype.
25. Which four utilities does Prototype use?
Answers:
• $B $w $Z $R
• $S $P $Q $R
• $P $w $H $Q
• $A $w $H $R
26. Select the wrong JavaScript-related MIME-types that handled by Prototype
Answers:
•
application/ext-javascript
• application/ecmascript
• text/javascript
• application/x-ecmascript
27. 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?
Answers:
• function(){ parent() }
•
function($super){ $super() }
• function(parent){ parent() }
• function($parent){ $parent() }
28. Despite DOM elements having Prototype extensions built-in, will they function in Internet Explorer?
Answers:
• Yes, but the configuration file
must be edited.
• Yes, but this action is not
supported by Internet Explorer.
• No.
• Yes, however Internet Explorer
crashes.
29. To use JSON with AJAX, what must be invoked on the transport's responseText property?
Answers:
• #evalJSON
• Object#evalJSON
• String#evalJSON
• String#evalJava
30. What property stores the active Ajax requests?
Answers:
• Ajax.active
•
Ajax.activeRequestCount
• There is no property set to the
number of active requests
• $.ajax.length
31. If you wanted to make Prototype extensions functional in Internet Explorer, what would you use?
Answers:
• Element.extend()
• Element.method
• Element.expand()
• Extend.element()
32. What solution has Prototype 1.7 introduced to provide a more concise API?
Answers:
• Element.Limit
• Element.Layout
• Event.Layout
• Element.Laundry
33. What is the right syntax of using Element#observe for the click event?
Answers:
•
$("element").observe("click", this.clickEventHandler);
•
$("element").observe("click", this.clickHandler);
•
#("element").observe("click", this.clickHandler);
•
#("element").observe("click", this.clickEventHandler);
34. What object is informed about every AJAX request?
Answers:
• Responders.Ajax
• Ajax.Responders
• Element.Ajax
• Ajax.Element
35. $w is responsible for?
Answers:
• Splitting a
string into an array.
• Splitting a string into a
larger string.
• Converting an array into an
object.
• Splitting an element into a
string.
36. What is the result of having the prototype of the native browser objects extended?
Answers:
• It is now possible to add
Prototype extensions.
• It is now possible to add
Prototype elements.
• All DOM
elements have Prototype extensions built-in.
• It is now possible to add Dom
elements.
37. What is the subclass of Ajax.Request, if any?
Answers:
• Ajax.Response
• Ajax.Updater
• Ajax.Request is not a class
• Ajax.EventObserver
38. Lets say you have an array with name myArray. How would you organize a loop?
Answers:
• Using "for" statement
or Array#iter iterator.
• Using
"for" statement or Array#each iterator.
• Using Array#prototype iterator
or "for" statement.
• Using "for" statement
only, Array#each is not an iterator.
39. How to receive width of an element with id='div1' in pixels?
Answers:
• by using #('div1').offsetWidth;
or by using #('div1').getStyle('width');
• by using $('div1').width; or by
using $('div1').getStyle('width');
• by using $('div1').clientWidth;
or by using $('div1').getStyle('width');
• by using
$('div1').offsetWidth; or by using $('div1').getStyle('width');
40. How can you create an instance of class Storage which has one parameter in constructor?
Answers:
• var inst = new
Storage("warehouse"');
• Storage.prototype = {
initialize: function(name) { this.name = name; }, f: function(message) { return
message+", "+this.name; } };
• var Storage =
Class.create("warehouse");
41. How would you remove a class named 'removeclass' from an element?
Answers:
• There is not a method to remove
class names
•
$('#element').className.replace('removeclass','');
•
$('element').removeClassName('removeclass');
•
$('#element').removeClass('removeclass');
42. Evaluate the following statement: Function class is an extension of a built-in Function object and has no class methods of its own.
Answers:
• Correct
• Correct for Prototype 1.7.2,
incorrect for Prototype 1.6.0
• Incorrect
• It is an extension of build-in
Function object but has at least one class method of its own
43. To make a contribution of patches or tests to prototypejs.org, you may NOT need:
Answers:
• A recent version of Ruby
• Rake library
• Gnu Linux
distributive installed on the machine you are working on
• Code editor
44. The IE properties, offsetWidth and clientHeight along with computed CSS are able to measure elements. Why not use them?
Answers:
• The version of Prototype has
changed so they are incompatible.
• There is no problem in using
them since they are powerful and accurate parameters.
• They are both outdated.
• IE properties
struggle with “offset” vs. “client” dimensions, and CSS units need to be
converted to be compatible.
45. When using data from an untrusted source, it should be sanitized. What does this entail?
Answers:
• Increasing malicious data in
user input.
• Removing
malicious data from user input.
• Removing all user input.
• Blocking users from entering
any input.
46. Element#on has what distinct and beneficial features in Prototype 1.7?
Answers:
• Better support for event
deletion and extended element handler removal.
• Better support for element
delegation and simplified event removal.
• Neglibable support for object
delegation and sanctified element handler removal.
• Better support
for event delegation and simplified event handler removal.
47. The actual Ajax requests are made by creating instances of
Answers:
• XmlHttpRequest object
• Ajax.Request
object
• Ajax.apicall object
• Ajax.Response object
48. What object would you use in Prototype, and what are the benefits of using said object?
Answers:
• PeriodicalUpdater – It
significantly reduces the load on your servers by increasing the number of
requests.
• Ajax.PeriodicalUpdater – It
significantly increases the load on your servers by reducing the number of
requests.
•
Ajax.PeriodicalUpdater – It significantly reduces the load on your servers by
reducing the number of requests.
• Ajax.Updater – It significantly
reduces the load on your servers by reducing the number of requests.
49. What is the alternative of Element.extend() function in Prototype?
Answers:
• createElement()
• The dollar
function $()
• addClassName()
• appendChild()
50. 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?
Answers:
• Nowhere in the string.
• At the beginning.
• At the end.
• In the middle.
51. 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?
Answers:
• Nowhere in the string.
• At the beginning.
• At the end.
• In the middle.
52. Instance method String#evalJSON():
Answers:
• Evaluates the string as JSON
and returns an integer
• Does not exist, it is a class
method
• Evaluates the string as JSON
and returns a string
• Evaluates the
string as JSON and returns the resulting object
53. 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?
Answers:
• Yes, by using
Ajax.Responders.on
• Yes, by using "var
callback = new Event.Handler(Ajax.Request req)" code snippet
• Yes, by using
Ajax.Responders.register
• No, to add a group of
responders to all Ajax requests you might need to use Abstract.EventObserver
class
54. What object is used to parse JSON?
Answers:
• String#evalJSON
• String#eval
• eval#StringJSON
• String#evalJava
55. What code will return an instance of Element.Layout?
Answers:
• $('#troz').getLayout();
• Get.Layout();var layout =
$('troz')
• var layout.getLayout();
• var layout =
$('troz').getLayout();
56. How can you get a copy of the array without any null or undefined values?
Answers:
• By calling Array#clean()
method.
• By calling Array#clear()
method.
• By calling
Array#compact() method.
• Although Array#compact() method
returns a copy of the array without undefined values it keeps null values.
There is a trick - write custom function to deal with null values.
57. Class method String#gsub:
Answers:
• Has second argument
"pattern"
• Returns the string with the
first occurence of a given pattern replaced by either a regular string, the
returned value of a function or a Template string
• Does not exist,
it is an instance method
• Returns boolean value
58. Internet Explorer doesn't allow the extension of what onto NodeList.prototype?
Answers:
• Numerable
• Numerical
• Enumerable
• NodeList
59. Which callback takes precedence: on<HTTP RESPONSE CODE>, onFailure, or onSuccess?
Answers:
• Neither
• on<HTTP
RESPONSE CODE>
• onSuccess
• onFailure
60. Which PrototypeJS method of functions have become a native method of functions?
Answers:
• None of these
• Function.methodize
• Function.bind
• Function.bindAsEventListener
61. "data-my-element-info-t".camelize() returns what?
Answers:
• A javascript error
• DataMyElementInfoT
• MyElementInfoT
• myelementinfot
•
dataMyElementInfoT
62. Prototype 1.6 introduced Element.Layout, which can be used for retrieving element measurements
Answers:
• Both statements are incorrect
• The second statement is
incorrect
• The first
statement is incorrect, right version of introduction is 1.7. Second statement
is correct for 1.7
• Correct
63. 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?
Answers:
•
Element.addMethods({'foo' : foo});
• $('emelent').foo() = foo
• $.fn.foo = foo;
64. Why would it be beneficial to use an array in Prototype?
Answers:
• By using an
array, Prototype has extended the number of usable methods.
• By using an array, Prototype
has decreased the number of usable elements.
• By using an array, Prototype
has decreased the number of usable objects.
• By using an array, Prototype
has decreased the number of usable methods.
65. When using Element#on as opposed to Element#observe, what is different about its return value?
Answers:
• Element#on has a #element
method which will remove excessive object handlers.
• Element#on has a #stop method
which will remove Element#observe events.
• Element#on has a #stop method
which will increase the number of event handlers.
• Element#on has
a #stop method which will remove excessive event handlers.
66. Here is a snapcode: ' bmw, bugatti & luxury'.scan(/\w+/, alert); How many alert dialongs will you see after executing given snapcode?
Answers:
• 3
• 5
• 2
• 4
67. Is there any utility to split a string into Array?
Answers:
• No, there is no such utility to
serve this purpose
• Yes, it calls
"split". Works fine for Prototype 1.6.0
• Yes, it treats all comas as
delimiters
• Yes, it treats
all whitespaces as delimiters
68. -background-color'.camelize(); returns:
Answers:
• backgroundColor
• -backgroundColor
• undefined
• null
69. When writing custom DOM methods, what must be placed as the first argument?
Answers:
• The method itself.
• The element
itself.
• The object itself.
• The method and object.
70. What do you use to add your own custom DOM methods?
Answers:
• Element.Methods
• addMethods.Element
• Element.Methods.add
•
Element.addMethods
71. The code: var json = transport.responseText.evalJSON(true); will check for what?
Answers:
• Missing user data.
• Malicious user
data.
• Incorrect user data.
• Excessive user data.
72. Why is event delegation important in Prototype?
Answers:
• It makes it impossible to
truncate resources to a single container.
• It makes it
possible to truncate resources to a single container.
• It makes it possible to extend
resources to multiple containers.
• It makes it impossible to
extend resources to a single element.
73. Which class serves a purpose of creation an observer on an element that listens for a particular event, that element's descendants?
Answers:
• Event.Handler
• Ajax.EventObserver
• Ajax.Event.Handler
• Event.Observer
74. Utilities $A and $R create an array and ObjectRange object. What will be their results given the following string; $A($R('a', 'e')) ?
Answers:
• ['a', 'e', 'e', 'e', 'a']
• ['a', 'e', 'a', 'e', 'e']
• ['a', 'b', 'a', 'b', 'e']
• ['a', 'b', 'c',
'd', 'e']
75. (42).toPaddedString(4) returns what?
Answers:
• 0042
• 42
• 042
• 4200
76. Which method that is not available to convert to JSON in Prototype
Answers:
• Number#toJSON
• Element#toJSON
• Array#toJSON
• String#toJSON
77. How would you wait for the DOM to be loaded so that you can start manipulating the page with Javascript?
Answers:
• document.ready(function(){
//code here });
• $(document).ready(function(){
//code here });
•
document.observe('dom:loaded',function(){ //code here });
78. Using Element.Layout you can measure elements that are hidden:
Answers:
• as long as
their parents are visible.
• always when
style="display: none"
• always when element has
"visibility: hidden"
• Impossible
79. If you want to create a distribution tarball in the pkg/ directory, what package would you run?
Answers:
• tar package
• rake package
• rke package
• tarball package
80. How would you create an AJAX call to get the url '/echomyid'?
Answers:
• $.ajax('/echomyid');
• ajax.get('/echomyid');
• get('/echomyid');
• new
Ajax.Request('/echomyid');
81. Is it required to use Element#on exclusively?
Answers:
• No. It is
perfectly acceptable to continue using Element#observe, though it is less
efficient.
• No. It is recommended that you
use Element#observe because it is more efficient.
• No. Neither of them are
recommended.
• Yes, though you can downgrade
the version and use Element#observe for better performance.
82. Which class serves the purpose of sophisticated string interpolation?
Answers:
• String
• ObjectRange
• Template
• RegExp
83. Prototype JS framework with version 1.6.0 defines two additional class properties:
Answers:
• subclass and superclass
• subclass and superclasses
• subclasses and superclasses
• subclasses and
superclass
84. After editing your browser script to work with Prototype extensions, what coding can you add to the end to make it function more solidly?
Answers:
• (my_div)Element.extend
•
Element.extend(my_div)
• Element.(my_div)
• Element.extend
85. What is the shortcut to get a Form element value?
Answers:
• $('#elementid').val()
• $F('elementid')
• $('element').value
• $('elementid).val()
86. The 'onSuccess' callback for any of the Ajax method will auto-convert responses to JSON if what takes place?
Answers:
• Ajax methods require the
'response':'json' option set
• Ajax methods will always
convert to JSON
• The Content
Type header is set to application/JSON
87. How would you loop over an array of elements (myArray) and set the value of each element to '1'?
Answers:
• $(myArray).val('1')
• $(myArray).each(function(index,element){
$(element).val('1'); });
• myArray.loop(function(element){
element.val('1'); });
•
myArray.each(function(element){ element.value = '1'; });
88. Is it possible to add a method to class "on-the-fly" in Prototype 1.7, and if so how?
Answers:
• Using
Class#addMethods.
• Using Class.extend only.
• Using Class#extend, for
instance.
• Using Class.extends.
• No it is not possible
89. DOM methods are mostly encapsulated by what object?
Answers:
• Object.Methods
• Method.Elements
• Element.Methods
• Object.Elements
90. What is printed in the console from the below statement console.log("PrototypeJS".blank());
Answers:
• undefined
• true
• Throws an Javascript Error
• 1
• false
91. 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.
Answers:
• One statement
is false
• One statement is true, the rest
are false
• At least two statements are
false for Prototype with versions below 1.7
• All premises are correct
92. Lets assume we are calling str.dasherize();. What should be a value of "str" to recieve "one-two-three" string as a result?
Answers:
• "one, two, three"
• "one two three"
•
"one_two_three"
• {"one",
"two", "three"}
93. After being encapsulated by Element.Methods, what object is it copied over to?
Answers:
• The Element
object.
• The Method object.
• The Order object.
• The Object Element
94. Which of the given examples returns "false"?
Answers:
• "{ \"foo\": 0
}".isJSON();
• "{ foo: 38
}".isJSON();
•
"\"38\"".isJSON();
• String#isJSON() does not exist
95. How would you select all of the child elements of a specific element that match a CSS selector (.myclass) ?
Answers:
•
$$('element').select('.myclass')
• $('element').down('.myclass')
• $('element .myclass')
•
$('element').select('.myclass')
96. Select the wrong callback function of Prototype's AJAX object
Answers:
• onCreate
• onUninitialized
• onError
• onInteractive
97. To make a contribution, a developer might need to make a clone of Prototype project from:
Answers:
• git://github.com/sstephenson/betaprototype.git
•
git://github.com/sstephenson/prototype.git
•
svn://bitbucket.com/sstephenson/prototypejs
•
git://github.com/sstephenson/prototypejs.git
98. How would you create a new div element and insert it as the last child of the body?
Answers:
•
$$('body').first().insert(new Element('div'));
• $('body').append(new
Element('div'));
• $('body').insert('div');
• $$('body').insert(new
Element('div'));
{ 0 comments... read them below or add one }
Post a Comment