In this post you can find Complete and recently updated Correct Question and answers of PrototypeJS Javascript Framework. All Answers updated regularly with new questions. Upwork PrototypeJS Javascript Framework test answers of 2016.
Question:* What is the correct syntax for a string of key-value pairs?
Answer: • company=example&limit=12
Question:* 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: • Has inner iterator
Question:* In the context of Prototype, “safe” means that AJAX will function how?
Answer: • Cross-browser
Question:* Prototype.K(43560) returns what?
Answer: • 43560
Question:* Which of the following is not a targeted platform for development?
Answer: • Netscape Navigator
Question:* The dollar sign method $() returns what?
Answer: • An DOM element that matches the id passed extended with Prototype methods
Question:* If you want to create a hash, which utility would you use?
Answer: • $H()
Question:* DOM is an acronym for?
Answer: • Document Object Model
Question:* Prototype is considered what kind of framework?
Answer: • A JavaScript framework for developing dynamic web applications.
Question:* What is JSON's meaning and purpose?
Answer: • JavaScript Object Notation, and JSON is a lightweight data-interchange format.
Question:* How can you inherit from a Storage class?
Answer: • After defining a descendant using Class.create() method, inherit from class Storage by using Object.extend() method.
Question:* How can you get access to the DOM element using Prototype?
Answer: • $(id) or $(element), where id is a string and element is an Element itself.
Question:* Which of the following is not an example of an AJAX callback?
Answer: • onInteractive
Question:* Which of these is NOT a namespace in PrototypeJS? Event Abstract Number Ajax Enumerable Class Hash
Answer: • All of these are namespaces in PrototypeJS
Question:* Which code segment has been written using Element#on?
Answer: • $("messages").on("click", "a.comment_link", function(event, element) {
Question:* Date class is an extension to the built-in Date object and has two instance methods:
Answer: • Correct
Question:* 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);
Answer: • 101
Question:* By using the Element#on object in Prototype event API, what benefit is being gained?
Answer: • Concisely written code and event delegation from within a container.
Question:* Element#measure(property) gives:
Answer: • pixel value of an element's dimension specified by property
Question:* Do Element.Layout#get and Element#measure work together?
Answer: • Yes.
Question:* Instance method String#extractScripts():
Answer: • Extracts the content of any <script> blocks present in the html page and returns them as an array of strings.
Question:* How to create (define) a class with the name Storage in Prototype Javascript framework?
Answer: • var Storage = Class.create();
Question:* Which namespace is not typically used directly but mixed in to other namespaces?
Answer: • Enumerable
Question:* 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
Question:* Which four utilities does Prototype use?
Answer: • $A $w $H $R
Question:* Select the wrong JavaScript-related MIME-types that handled by Prototype
Answer: • application/ext-javascript
Question:* 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: • function($super){ $super() }
Question:* Despite DOM elements having Prototype extensions built-in, will they function in Internet Explorer?
Answer: • No.
Question:* To use JSON with AJAX, what must be invoked on the transport's responseText property?
Answer: • String#evalJSON
Question:* What property stores the active Ajax requests?
Answer: • Ajax.activeRequestCount
Question:* If you wanted to make Prototype extensions functional in Internet Explorer, what would you use?
Answer: • Element.extend()
Question:* What solution has Prototype 1.7 introduced to provide a more concise API?
Answer: • Element.Layout
Question:* What is the right syntax of using Element#observe for the click event?
Answer: • $("element").observe("click", this.clickHandler);
Question:* What object is informed about every AJAX request?
Answer: • Ajax.Responders
Question:* $w is responsible for?
Answer: • Splitting a string into an array.
Question:* What is the result of having the prototype of the native browser objects extended?
Answer: • All DOM elements have Prototype extensions built-in.
Question:* What is the subclass of Ajax.Request, if any?
Answer: • Ajax.Updater
Question:* Lets say you have an array with name myArray. How would you organize a loop?
Answer: • Using "for" statement or Array#each iterator.
Question:* How to receive width of an element with id='div1' in pixels?
Answer: • by using $('div1').offsetWidth; or by using $('div1').getStyle('width');
Question:* How can you create an instance of class Storage which has one parameter in constructor?
Answer: • var inst = new Storage("warehouse"');
Question:* How would you remove a class named 'removeclass' from an element?
Answer: • $('element').removeClassName('removeclass');
Question:* 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
Question:* To make a contribution of patches or tests to prototypejs.org, you may NOT need:
Answer: • Gnu Linux distributive installed on the machine you are working on
Question:* The IE properties, offsetWidth and clientHeight along with computed CSS are able to measure elements. Why not use them?
Answer: • IE properties struggle with “offset” vs. “client” dimensions, and CSS units need to be converted to be compatible.
Question:* When using data from an untrusted source, it should be sanitized. What does this entail?
Answer: • Removing malicious data from user input.
Question:* Element#on has what distinct and beneficial features in Prototype 1.7?
Answer: • Better support for event delegation and simplified event handler removal.
Question:* The actual Ajax requests are made by creating instances of
Answer: • Ajax.Request object
Question:* What object would you use in Prototype, and what are the benefits of using said object?
Answer: • Ajax.PeriodicalUpdater – It significantly reduces the load on your servers by reducing the number of requests.
Question:* What is the alternative of Element.extend() function in Prototype?
Answer: • The dollar function $()
Question:* 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: • At the end.
Question:* 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: • At the end.
Question:* Instance method String#evalJSON():
Answer: • Evaluates the string as JSON and returns the resulting object
Question:* 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: • Yes, by using Ajax.Responders.register
Question:* What object is used to parse JSON?
Answer: • String#evalJSON
Question:* What code will return an instance of Element.Layout?
Answer: • var layout = $('troz').getLayout();
Question:* How can you get a copy of the array without any null or undefined values?
Answer: • By calling Array#compact() method.
Question:* Class method String#gsub:
Answer: • Does not exist, it is an instance method
Question:* Internet Explorer doesn't allow the extension of what onto NodeList.prototype?
Answer: • Enumerable
Question:* Which callback takes precedence: on<HTTP RESPONSE CODE>, onFailure, or onSuccess?
Answer: • on<HTTP RESPONSE CODE>
Question:* Which PrototypeJS method of functions have become a native method of functions?
Answer: • Function.bind
Question:* "data-my-element-info-t".camelize() returns what?
Answer: • dataMyElementInfoT
Question:* Prototype 1.6 introduced Element.Layout, which can be used for retrieving element measurements
Answer: • The first statement is incorrect, right version of introduction is 1.7. Second statement is correct for 1.7
Question:* 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: • Element.addMethods({'foo' : foo});
Question:* Why would it be beneficial to use an array in Prototype?
Answer: • By using an array, Prototype has extended the number of usable methods.
Question:* When using Element#on as opposed to Element#observe, what is different about its return value?
Answer: • Element#on has a #stop method which will remove excessive event handlers.
Question:* Here is a snapcode: ' bmw, bugatti & luxury'.scan(/\w+/, alert); How many alert dialongs will you see after executing given snapcode?
Answer: • 3
Question:* Is there any utility to split a string into Array?
Answer: • Yes, it treats all whitespaces as delimiters
Question:* -background-color'.camelize(); returns:
Answer: • backgroundColor
Question:* When writing custom DOM methods, what must be placed as the first argument?
Answer: • The element itself.
Question:* What do you use to add your own custom DOM methods?
Answer: • Element.addMethods
Question:* The code: var json = transport.responseText.evalJSON(true); will check for what?
Answer: • Malicious user data.
Question:* Why is event delegation important in Prototype?
Answer: • It makes it possible to truncate resources to a single container.
Question:* Which class serves a purpose of creation an observer on an element that listens for a particular event, that element's descendants?
Answer: • Event.Handler
Question:* Utilities $A and $R create an array and ObjectRange object. What will be their results given the following string; $A($R('a', 'e')) ?
Answer: • ['a', 'b', 'c', 'd', 'e']
Question:* (42).toPaddedString(4) returns what?
Answer: • 0042
Question:* Which method that is not available to convert to JSON in Prototype
Answer: • Element#toJSON
Question:* How would you wait for the DOM to be loaded so that you can start manipulating the page with Javascript?
Answer: • document.observe('dom:loaded',function(){ //code here });
Question:* Using Element.Layout you can measure elements that are hidden:
Answer: • as long as their parents are visible.
Question:* If you want to create a distribution tarball in the pkg/ directory, what package would you run?
Answer: • rake package
Question:* How would you create an AJAX call to get the url '/echomyid'?
Answer: • new Ajax.Request('/echomyid');
Question:* Is it required to use Element#on exclusively?
Answer: • No. It is perfectly acceptable to continue using Element#observe, though it is less efficient.
Question:* Which class serves the purpose of sophisticated string interpolation?
Answer: • Template
Question:* Prototype JS framework with version 1.6.0 defines two additional class properties:
Answer: • subclasses and superclass
Question:* 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: • Element.extend(my_div)
Question:* What is the shortcut to get a Form element value?
Answer: • $F('elementid')
Question:* The 'onSuccess' callback for any of the Ajax method will auto-convert responses to JSON if what takes place?
Answer: • The Content Type header is set to application/JSON
Question:* How would you loop over an array of elements (myArray) and set the value of each element to '1'?
Answer: • myArray.each(function(element){ element.value = '1'; });
Question:* Is it possible to add a method to class "on-the-fly" in Prototype 1.7, and if so how?
Answer: • Using Class#addMethods.
Question:* DOM methods are mostly encapsulated by what object?
Answer: • Element.Methods
Question:* What is printed in the console from the below statement console.log("PrototypeJS".blank());
Answer: • false
Question:* 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: • One statement is false
Question:* Lets assume we are calling str.dasherize();. What should be a value of "str" to recieve "one-two-three" string as a result?
Answer: • "one_two_three"
Question:* After being encapsulated by Element.Methods, what object is it copied over to?
Answer: • The Element object.
Question:* Which of the given examples returns "false"?
Answer: • "{ foo: 38 }".isJSON();
Question:* How would you select all of the child elements of a specific element that match a CSS selector (.myclass) ?
Answer: • $('element').select('.myclass')
Question:* Select the wrong callback function of Prototype's AJAX object
Answer: • onError
Question:* To make a contribution, a developer might need to make a clone of Prototype project from:
Answer: • git://github.com/sstephenson/prototype.git
Question:* How would you create a new div element and insert it as the last child of the body?
Answer: • $$('body').first().insert(new Element('div'));
No comments:
Post a Comment