Using Swap in Pas2JS

Top 

Example code : Using Swap in Pas2JS

var

  fruits : array of String = ["Banana", "Orange", "Apple", "Mango", "Banana", "Abacate", "Apple"];

begin

  fruits.swap(1,2);

  for var Index := Low(fruits) to High(fruits) do

     WriteLn( fruits[Index] );

Banana

Apple

Orange

Mango

Banana

Abacate

Apple

-------------

 

JS output:

      var fruits = [];

      var fruits = ["Banana","Orange","Apple","Mango","Banana","Abacate","Apple"].slice();

      var Index = 0;

      $ArraySwapChk(fruits,1,2,"");

      var $temp24;

      for(Index = 0,$temp24 = fruits.length;Index<$temp24;Index++) {

         WriteLn($DIdxR(fruits,Index,""));