Prototype Interview Questions

tutorial and example
tutorial and example

1) What is Prototype?

Prototype is a JavaScript framework which is used in dynamic web applications.

It is a namespace and a module that is used to manage HTML forms.

It is also a JavaScript Library.

2) Who is the developer of Prototype?

Sam Stephenson is the developer of Prototype.

3) What are the features of Prototype?

The features of Prototype are:

  • Extends DOM elements
  • Powerful Ajax features
  • Does not provide widgets
  • Advanced support for event management
  • It is not a complete application development framework
  • Built-in support for class-style OOP including inheritance

4) What are the types of String Methods are available in Prototype?

Prototype String Methods:

blank() camelize() inspect() strip() toJSON()
capitalize() dasherize() interpolate() stripScripts() succ()
empty() endsWith() isJSON() stripTags() toQueryParams()
escapeHTML() extractScripts() startsWith() sub() truncate()
evalJSON() gsub() parseQuery() toArray() unescapeHTML()
evalScripts() include() scan() times() underscore()

5) What is underscore() method in Prototype String Method?

underscore() method: This method is used to converts a String into a series of words separated by an underscore.

6) What is inspect() method in Prototype String Method?

inspect() method: This method is used to returns a debug-oriented version of the string.

7) What is empty() method in Prototype Element Method?

empty() method is used to check whether the element is empty or not.

8) What is Templates in Prototype?

Templates:

It is used for formatting group of similar objects.

It is also used to produce formatted output for these objects.

9) What are the steps to create the formatted output in Prototype?

The steps to create the formatted output are:

  • Step1: Create a template
  • Step2: Defining actual values
  • Step3: Mapping Keys and replacing Values

10) What is include() method in Prototype?

include method: This method is used to determine whether the value is included in the range or not.

If the value is included, then returns true otherwise returns false.

11) What is $A() method in Prototype?

$A() method: This method is used to converts the single argument it receives into an array object.

12) What is $w() method in Prototype?

The $w() method is used to splits a string into an array.

Here, all whitespace are treated as delimiters.

13) What is AJAX in Prototype?

AJAX stands for Asynchronous JavaScript and XML.

It is a technique which is used for creating faster, better and more interactive web applications.

14) What is Date.toJSON() in Prototype?

The Date.toJSON() method is used to convert the date into a JSON string.

15) What are the ways to construct a Hash instance in Prototype?

Two ways to construct a Hash instance are:

  • By using new JavaScript keyword
  • By using $H(Prototype Utility function)

16) What is the use of PeriodicalExecuter object?

PeriodicalExecuter object: It is used to execute a function many times after a certain period of time.

17) What is the major advantage of PeriodicalExecuter?

The major advantage of PeriodicalExecuter is: PeriodicalExecuter shields you against multiple parallel executions of the callback function.

18) What is the syntax of $R utility function in Prototype?

The syntax of $R utility function is: $R(start, end[, exclusive = false]);

Example:

$R(1, 10).inspect();

)19) What are the AJAX methods available in Prototype?

The AJAX methods available in Prototype are:

20) Name some callbacks that are not implemented by all browsers?

Callbacks that are not implemented by all browsers are:

  • onLoaded
  • onLoading
  • onInteractive
  • onUninitialized

21) What are the methods provided by JSON for Encoding in Prototype?

The methods provided by JSON for Encoding are:

  • Number.toJSON()
  • String.toJSON()
  • Array.toJSON()
  • Hash.toJSON()
  • Date.toJSON()
  • Object.toJSON()

22) What are the features of JSON (JavaScript Object Notation)?

The features of JSON are:

  • JSON is a lightweight data-interchange format
  • Easy to read and write for humans
  • Easy to parse and generate for machines
  • Based on JavaScript Programming Language
  • Completely language independent

23) What is the use of $H method in Prototype?

$H method: This method is used to convert object into enumerable Hash object.

Syntax:$H([obj])

24) What will be the output of the following code snippet?

Output: { foo: 0, Tuto: 1, rial: 2}

25) What is the syntax of pluck() method in Prototype?

The syntax of pluck() method is: Iterator.pluck(propertyName);

26) What is the use of isHash() method in Prototype?

isHash() method: Returns true if object is an instance of the Hash class, Otherwise returns false.

27) What are the form methods available in Prototype?

The form methods available in Prototype are:

28) What is the use of isJSON() method in Prototype?

isJSON() method: It is used to check the string is valid JSON with the help of regular expressions.