Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel2

...

Description

Returns the last index at which a given element can be found in the array.

This is similar to the JavaScript lastIndexOf.

Syntax
Code Block
array.lastIndexOf(element)
Examples

Expression: $first.lastIndexOf(0)

where $first contains [0, 2, 4, 6, 8]

Result: 0

Anchor
length
length
length

Description

The number of elements in an array.

This is similar to the JavaScript length.

Syntax
Code Block
array.length
Examples

Expression: $array.length

Result: A number.

Anchor
join
join
join

Description

Joins all elements of an array into a string.

This is similar to the JavaScript join.

Syntax
Code Block
array.join(optseparator)

where optseparator is an optional string to separate the elements. If omitted, a comma is used.

Examples

Expression: ["SnapLogic", "Data", "Integration"].join(" ")

Result: the string SnapLogic Data Integration

Anchor
map
map
map

Description

Returns a new array with the values transformed by the given callback.
This is similar to the JavaScript Array.map() method.

Syntax
Code Block
array.map(callback)
Examples

Expression: $myarray.map(x => x * 10)

where $myarray is an array

Result: A new array where the elements have been multiplied by ten.

Anchor
pop
pop
pop

Description

Removes the last element from an array and returns that element.

This is similar to the JavaScript pop.

Syntax
Code Block
array.pop()
Examples

Expression: $Array.pop()

Result: The last element of the array.

Anchor
push
push
push

Description

Adds one or more elements to the end of an array and returns the new length of the array.

This is similar to the JavaScript push.

Syntax
Code Block
array.push(element1, ..., elementN)
Examples

Expression: $Array.push("Mobile", "Email")

Result: Mobile and Email will be added to that array and the new length of the array is returned.

Anchor
reduce
reduce
reduce

DescriptionReduces an array to a single value using the given callback. For each element in the array, the callback is called with four arguments: the accumulated value (the result from previous calls or the initialValue), the value of the current element, the index of the current element, and the array itself.  The exact behavior will change based on whether an initial value is provided.  If no value is provided, the callback is called with the first element in the array as the accumulated value and the second element as the current value.  If an initial value is provided, then the first call uses the initial value as the accumulated value and the first element as the current value.  In general, it is safest to provide an initial value.
This is similar to the JavaScript Array.reduce() method.
Syntax
Code Block
array.reduce(callback, [initialValue])
Examples

Expression: $myarray.reduce((accum, currentValue) => accum + currentValue, 0)

where $myarray is an array

Result: The sum of all of the elements in the array.

Anchor
reduceRight
reduceRight
reduceRight

DescriptionLike the reduce() method, except the elements are traversed right-to-left instead of left-to-right.
This is similar to the JavaScript Array.reduceRight() method.
Syntax
Code Block
array.reduceRight(callback, [initialValue])
Examples

Expression: $myarray.reduceRight((accum, currentValue) => accum + currentValue, "")

where $myarray is an array

Result: Builds a string of the elements in reverse order.

Anchor
reverse
reverse
reverse

Description

Transposes the elements of the calling array object in place, mutating the array, and returning a reference to the array.

This is similar to the JavaScript reverse.

Syntax
Code Block
array.reverse
Examples

Expression: $Array.reverse

Result: Returns the array in reverse order.

Anchor
shift
shift
shift

Description

Removes the first element from an array and returns that element. This method changes the length of the array.

This is similar to the JavaScript shift.

Syntax
Code Block
array.shift()
Examples

Expression: $Array.shift()

Result: The first element from an array.

Anchor
slice
slice
slice

Description

Returns a shallow copy of an array containing copies of the original elements.

This is similar to the JavaScript slice.

Syntax
Code Block
array.slice(begin,end)
Examples

Expression: $Array.slice(1,3)

where $Array contains [0, 2, 4, 6, 8]

Result: [2,4]

Anchor
sort
sort
sort

Description

Returns a sorted array.

This is similar to the JavaScript sort.

Syntax
Code Block
array.sort()
Examples

Expression: $Array.sort()

Result: A sorted array.

Anchor
splice
splice
splice

Description

Lets you remove and insert elements in an array and returns an array containing the elements removed

This is similar to the JavaScript splice.

Syntax
Code Block
array.splice(begin,digit,item...)

where:

  • begin is the index where to start changing the array
  • digit is the number of items to remove
  • item is the items to insert
Examples

For an array, $Contacts, defined as:

Code Block
[
  {
    "Contacts": [
      "First",
      "Last",
      "Street",
      "City",
      "Zip"
    ]
  }
]


Expression: $Contacts.splice(2,0,'Business')

Result: Removes nothing, but inserts "Business" after "Last".


Expression: $Contacts.splice(4,1,'State')

Result: Removes "Zip", inserts "State", returns "Zip" in the output view.

Anchor
toString
toString
toString

Description

Returns one string containing each array element separated by commas.

This is similar to the JavaScript toString.

Syntax
Code Block
array.toString()
Examples

Expression: $Array.toString()

Result: Returns a string containing a comma-separated list of the array elements.

Anchor
unshift
unshift
unshift

Description

Adds the specified elements to the beginning of an array and returns the new length of the array.

This is similar to the JavaScript unshift.

Syntax
Code Block
array.unshift(element...)
Examples

Expression: $Contacts.unshift('Title')

Result: Adds "Title" to the beginning of the array and returns the new array length.

...