Prototype Tutorial
Prototype Useful Resources
Selected Reading
- Prototype - Periodical Execution
- Prototype - Expressing Ranges
- Prototype - AJAX Support
- Prototype - JSON Support
- Prototype - Form Management
- Prototype - Event Handling
- Prototype - Enumerating
- Prototype - Templating
- Prototype - Basic Object
- Prototype - Hash processing
- Prototype - Array Processing
- Prototype - Strings Processing
- Prototype - Number Processing
- Prototype - Element Object
- Prototype - Utility Methods
- Prototype - Useful Features
- Prototype - Short Overview
- Prototype - Home
Prototype Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Prototype - Expressing Ranges
Prototype - Expressing Range
Prototype Ranges represent an interval of values. The preferred way to obtain a range is to use the $R utipty function.
You can create a big range of values using a simple syntax as follows −
$R(1, 10).inspect(); $R( a , e ).inspect();
This will produce the following result −
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] [ a , b , c , d , e ]
The include() Method
This method determines whether the value is included in the range −
Syntax
Range.include(value);
Return Value
If value is included, then returns a true value otherwise false.
Example
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function showResult() { alert ( "Test 1 : " + $R(1, 10).include(5)); // Returns true alert ( "Test 2 : " + $R( a , h ).include( x )); // Returns flase } </script> </head> <body> <p>Cpck the button to see the result.</p> <br /> <br /> <input type = "button" value = "Result" oncpck = "showResult();"/> </body> </html>