Using Delete to erase an item in Pas2JS

Top 

Example code : Deleting item "orange"

var

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

begin

  fruits.Delete(11);

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

     WriteLn( fruits[Index] );

Result is:

Banana

Apple

Mango

Laranja

Abacate

Abacaxi

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

 

 

Example code : Delete the items "Orange", "Apple", "Mango", "Laranja"

var

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

begin

  fruits.Delete(14);

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

     WriteLn( fruits[Index] );

Result is:

Banana

Abacate

Abacaxi

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

 

JS output:

 var fruits = [];

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

 var Index = 0;

      fruits.splice(1,4);

      var $temp24;

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

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

      }