PP.rmvFrmArrByIdx

Syntax

rmvFrmArrByIdx(arr: Array, first: Number, last: Number);

Parameters

arr. Initial array of elements.

first. Index of the first element to remove.

last. Index of the second element to remove.

Description

The rmvFrmArrByIdx method removes elements from the array in specified range.

Comments

This method returns True if elements are successfully removed from the array, otherwise it returns False.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Determine an array of integers and remove elements with the indices 2 to 4 (inclusive) from this array:

// Determine an integer array
var elements = [5, 9, 6, 7, 2];
console.log("Source array of elements: [" + elements + "]");
// Remove element with indexes from 2 to 4 inclusive from the array:
var first = 2;
var last = 4;
if (elements.length <= first | elements.length <= last) {
    throw PP.OutOfRangeException("Incorrect element index", this);
};
if (first > last) {
    throw PP.NotSupportedException("First element must be less then last element", this);
};
PP.rmvFrmArrByIdx(elements, 2, 4);
console.log("Changed array of elements: [" + elements + "]");

After executing the example elements with the indices 2 to 4 are removed from the specified array:

Initial array of elements: [5,9,6,7,2]

Modified array of elements: [5,9]

See also:

PP