Copyright ©

Prototype Enumerable zip() Method

previous next


This method zips together 2 + sequences, providing an array of tuples.

Each tuple contains one value per original sequence. Tuples can be converted to something else by applying the optional iterator on them.


Return Value :


<title>Prototype examples</title>
<script type="text/javascript" 


function showResult(){
  var firstNames = ['Justin', 'Tobie', 'Christophe'];
  var lastNames = ['Palmer', 'Langel', 'Porteneuve'];
  var zipped =;

  alert("zipped values: " + zipped.inspect());

  var zipped =, function(a)
			      return a.join(' '); 
  alert("zipped values: " + zipped.inspect());



  <p>Click the button to see the result.</p>
  <br />
  <br />
  <input type="button" value="Result" onclick="showResult();"/>


To understand it in better way you can Try it yourself.

previous next

Copyright ©