Elance PrototypeJS Javascript Framework Test Answers



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

example&limit=12company=
company=example&limit=12
&limit=12
company=limit=12

 

 

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

Incorrect
Correct for Prototype 1.7.2, incorrect for Prototype 1.6.0
Correct
It is an extension of build-in Function object but has at least one class method of its own

 

 

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

Rake library
Gnu Linux distributive installed on the machine you are working on
A recent version of Ruby
Code editor

 

 

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

onException
onInteractive
onComplete
onSuccess

 

 

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

application/ecmascript
application/ext-javascript
application/x-ecmascript
text/javascript

 

 

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

Abstract
Hash
Number
All of these are namespaces in PrototypeJS
Class

 

 

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

$H()
$F()
$Z()
$Q()

 

 

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

Yes.
Not currently, but in the next version of Prototype.
No.
Only in the previous version of Prototype.

 

 

How can you inherit from a Storage class?

After defining a Descendant using Class.create() method, inherit from class Storage by calling Descendant.inherits() method.
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.
var Descendant = new Class(Storage, { newmethod: function() { } });

 

 

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

Netscape Navigator
Mozilla Firefox
Apple Safari
Microsoft Internet Explorer

 

 

Which namespace is not typically used directly but mixed in to other namespaces?

Array
String
Enumerable
Number
Template

 

 

Instance method String#extractScripts():

Extracts the content of any <script> blocks present in the html page and returns them as a string.
It evaluates the scripts
Returns boolean
Extracts the content of any <script> blocks present in the html page and returns them as an array of strings.

 

 

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);

101
true
1
100
None of these

 

 

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

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

 

 

Element#measure(property) gives:

pixel value of an element's dimension specified by property
nothing because it does not exist
pixel value of the screen dimension specified by property
value(not only in pixels) of the screen dimension specified by property

 

 

In the context of Prototype, “safe” means that AJAX will function how?

Inter-browser.
Cross-browser
On a single browser.
On no browser at all.

 

 

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

appendChild()
The dollar function $()
createElement()
addClassName()

 

 

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

Enumerable
NodeList
Numerical
Numerable

 

 

What object is informed about every AJAX request?

Ajax.Responders
Element.Ajax
Ajax.Element
Responders.Ajax

 

 

Instance method String#evalJSON():

Evaluates the string as JSON and returns the resulting object
Does not exist, it is a class method
Evaluates the string as JSON and returns an integer
Evaluates the string as JSON and returns a string

 

 

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

Correct. In addition to the given statement it has one class method.
The second statement is incorrect
The first statement is incorrect
Correct

 

 

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

Obtusely written code and event delegation from within an object.
Concisely written code and event delegation from outside a container.
Negligible written code and object delegation from within a container.
Concisely written code and event delegation from within a container.

 

 

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

by using $('div1').clientWidth; or by using $('div1').getStyle('width');
by using $('div1').offsetWidth; or by using $('div1').getStyle('width');
by using $('div1').width; or by using $('div1').getStyle('width');
by using #('div1').offsetWidth; or by using #('div1').getStyle('width');

 

 

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?

$.fn.foo = foo;
$('emelent').foo() = foo
Element.addMethods({'foo' : foo});

 

 

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

IE properties struggle with “offset” vs. “client” dimensions, and CSS units need to be converted to be compatible.
The version of Prototype has changed so they are incompatible.
They are both outdated.
There is no problem in using them since they are powerful and accurate parameters.

 

 

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

Element.extend(my_div)
Element.(my_div)
Element.extend
(my_div)Element.extend

 

 

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?

function(){ parent() }
function($super){ $super() }
function($parent){ $parent() }
function(parent){ parent() }

 

 

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

Removing all user input.
Removing malicious data from user input.
Blocking users from entering any input.
Increasing malicious data in user input.

 

 

The dollar sign method $() returns what?

An DOM element that matches the id passed extended with Prototype methods
Nothing
An document element that matches the id passed
A list of DOM elements that match the CSS selector passed
Boolean true

 

 

What is JSON's meaning and purpose?

JavaScript Oblique Nation, and JSON is a lightweight data-interchange function.
JavaScript Object Notation, and JSON is a lightweight data-interchange format.
JavaScript Order Notion, and JSON is a lightweight data-interchange format.
JavaJava Orbit Notation, and JSON is a lightweight data-conversion format.

 

 

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

It is now possible to add Dom elements.
It is now possible to add Prototype elements.
It is now possible to add Prototype extensions.
All DOM elements have Prototype extensions built-in.

 

 

DOM is an acronym for?

Direct Object Management
Document Oriented Model
Document Order Maintenance
Document Object Model

 

 

Which code segment has been written using Element#on?

$$('#items li').each( function(item) {
$("messages").on("click", "a.comment_link", function(event, element) {
$("messages").stopObserving("click", this.clickHandler);
$("messages").observe("click", function(event) {

 

 

Prototype.K(43560) returns what?

250
1
43560
5

 

 

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

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

 

 

Element#on has what distinct and beneficial features in Prototype 1.7?

Better support for event deletion and extended element handler removal.
Better support for element delegation and simplified event removal.
Better support for event delegation and simplified event handler removal.
Neglibable support for object delegation and sanctified element handler removal.

 

 

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

Element.Layout
Event.Layout
Element.Limit
Element.Laundry

 

 

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

var Storage = Class.create();
className = function() {}; Storage = new className();
var Storage = Class.extend({ init: function(item){ this.item = item; }, doSomething: function() { } });
var Storage = new Object();

 

 

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

onSuccess
onFailure
on<HTTP RESPONSE CODE>
Neither

 

 

What object is used to parse JSON?

eval#StringJSON
String#eval
String#evalJava
String#evalJSON

 

 

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

$('#element').className.replace('removeclass','');
$('element').removeClassName('removeclass');
$('#element').removeClass('removeclass');
There is not a method to remove class names

 

 

What code will return an instance of Element.Layout?

var layout = $('troz').getLayout();
$('#troz').getLayout();
Get.Layout();var layout = $('troz')
var layout.getLayout();

 

 

The actual Ajax requests are made by creating instances of

Ajax.apicall object
XmlHttpRequest object
Ajax.Request object
Ajax.Response object

 

 

Which four utilities does Prototype use?

$A $w $H $R
$P $w $H $Q
$B $w $Z $R
$S $P $Q $R

 

 

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?

At the end.
Nowhere in the string.
In the middle.
At the beginning.

 

 

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

More than one statements are incorrect.
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.
Correct

 

 

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

Extend.element()
Element.method
Element.extend()
Element.expand()

 

 

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

Using "for" statement or Array#each iterator.
Using "for" statement only, Array#each is not an iterator.
Using Array#prototype iterator or "for" statement.
Using "for" statement or Array#iter iterator.

 

 

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

No.
Yes, but this action is not supported by Internet Explorer.
Yes, however Internet Explorer crashes.
Yes, but the configuration file must be edited.

 

 

What property stores the active Ajax requests?

There is no property set to the number of active requests
Ajax.active
$.ajax.length
Ajax.activeRequestCount

 

 

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

#evalJSON
String#evalJSON
String#evalJava
Object#evalJSON

 

 

$w is responsible for?

Splitting an element into a string.
Splitting a string into a larger string.
Converting an array into an object.
Splitting a string into an array.

 

 

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

$("element").observe("click", this.clickHandler);
#("element").observe("click", this.clickEventHandler);
#("element").observe("click", this.clickHandler);
$("element").observe("click", this.clickEventHandler);

 

 

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

By using an array, Prototype has decreased the number of usable elements.
By using an array, Prototype has extended the number of usable methods.
By using an array, Prototype has decreased the number of usable methods.
By using an array, Prototype has decreased the number of usable objects.

 

 

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

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
Both statements are incorrect

 

 

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?

Creates an instance of Event.Handler
It works just like Event.observe
It calls Event.Handler#start
Has inner iterator

 

 

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

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");

 

 

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?

Yes, by using "var callback = new Event.Handler(Ajax.Request req)" code snippet
No, to add a group of responders to all Ajax requests you might need to use Abstract.EventObserver class
Yes, by using Ajax.Responders.on
Yes, by using Ajax.Responders.register

 

 

Prototype is considered what kind of framework?

A programming framework.
A network framework.
A JavaScript framework for developing dynamic web applications.
An HTML framework.

 

 

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

dataMyElementInfoT
DataMyElementInfoT
MyElementInfoT
A javascript error
myelementinfot

 

 

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

Ajax.Request is not a class
Ajax.EventObserver
Ajax.Response
Ajax.Updater

 

 

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

Ajax.Updater – It significantly reduces the load on your servers by reducing the number of requests.
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.

 

 

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

$$('body').insert(new Element('div'));
$$('body').first().insert(new Element('div'));
$('body').insert('div');
$('body').append(new Element('div'));

 

 

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

By calling Array#clean() method.
By calling Array#clear() 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.
By calling Array#compact() method.

 

 

DOM methods are mostly encapsulated by what object?

Element.Methods
Object.Methods
Object.Elements
Method.Elements

 

 

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

ajax.get('/echomyid');
$.ajax('/echomyid');
new Ajax.Request('/echomyid');
get('/echomyid');

 

 

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

Ajax.EventObserver
Ajax.Event.Handler
Event.Observer
Event.Handler

 

 

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

Missing user data.
Incorrect user data.
Malicious user data.
Excessive user data.

 

 

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

The object itself.
The element itself.
The method itself.
The method and object.

 

 

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

Number#toJSON
Array#toJSON
Element#toJSON
String#toJSON

 

 

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

Function.bindAsEventListener
None of these
Function.methodize
Function.bind

 

 

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

Element.Methods
addMethods.Element
Element.addMethods
Element.Methods.add

 

 

Class method String#gsub:

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
Returns boolean value
Does not exist, it is an instance method
Has second argument "pattern"

 

 

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

always when element has "visibility: hidden"
as long as their parents are visible.
always when style="display: none"
Impossible

 

 

(42).toPaddedString(4) returns what?

0042
42
4200
042

 

 

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

Ajax methods will always convert to JSON
Ajax methods require the 'response':'json' option set
The Content Type header is set to application/JSON

 

 

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

Element#on has a #stop method which will increase the number of event handlers.
Element#on has a #stop method which will remove Element#observe events.
Element#on has a #stop method which will remove excessive event handlers.
Element#on has a #element method which will remove excessive object handlers.

 

 

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

2
4
3
5

 

 

Why is event delegation important in Prototype?

It makes it possible to truncate resources to a single container.
It makes it impossible 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.

 

 

Is there any utility to split a string into Array?

Yes, it treats all comas as delimiters
No, there is no such utility to serve this purpose
Yes, it treats all whitespaces as delimiters
Yes, it calls "split". Works fine for Prototype 1.6.0

 

 

Is it required to use Element#on exclusively?

Yes, though you can downgrade the version and use Element#observe for better performance.
No. Neither of them are recommended.
No. It is recommended that you use Element#observe because it is more efficient.
No. It is perfectly acceptable to continue using Element#observe, though it is less efficient.

 

 

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

null
undefined
backgroundColor
-backgroundColor

 

 

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

The Method object.
The Element object.
The Object Element
The Order object.

 

 

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

subclasses and superclass
subclass and superclasses
subclass and superclass
subclasses and superclasses

 

 

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

['a', 'b', 'c', 'd', 'e']
['a', 'e', 'a', 'e', 'e']
['a', 'b', 'a', 'b', 'e']
['a', 'e', 'e', 'e', 'a']

 

 

Which class serves the purpose of sophisticated string interpolation?

String
ObjectRange
RegExp
Template

 

 

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

rake package
tar package
rke package
tarball package

 

 

What is the shortcut to get a Form element value?

$('elementid).val()
$('#elementid').val()
$('element').value
$F('elementid')

 

 

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

myArray.each(function(element){ element.value = '1'; });
$(myArray).each(function(index,element){ $(element).val('1'); });
myArray.loop(function(element){ element.val('1'); });
$(myArray).val('1')

 

 

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

Using Class.extend only.
Using Class.extends.
Using Class#extend, for instance.
Using Class#addMethods.
No it is not possible

 

 

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

undefined
1
false
Throws an Javascript Error
true

 

 

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

$('element .myclass')
$('element').down('.myclass')
$('element').select('.myclass')
$$('element').select('.myclass')

 

 

Select the wrong callback function of Prototype's AJAX object

onUninitialized
onInteractive
onCreate
onError

 

 

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

"one_two_three"
{"one", "two", "three"}
"one, two, three"
"one two three"

 

 

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.

One statement is false
All premises are correct
At least two statements are false for Prototype with versions below 1.7
One statement is true, the rest are false

 

 

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

git://github.com/sstephenson/betaprototype.git
svn://bitbucket.com/sstephenson/prototypejs
git://github.com/sstephenson/prototypejs.git
git://github.com/sstephenson/prototype.git

 

 

Which of the given examples returns "false"?

"\"38\"".isJSON();
"{ \"foo\": 0 }".isJSON();
String#isJSON() does not exist
"{ foo: 38 }".isJSON();