.prepend(val)

Description

Prepend is a simple method that returns the input value you give it, but with a new value attached to the start.

Parameters

Prepend takes only one parameter, and will treat multiple parameters as one parameter

Usage On Arrays

arr = ["wow"]
// setup the array

arr.prepend("hello world")
// i use a method as a command so that it updates the variable
// prepend adds the new value as the first item in the array

log arr
// returns ["hello world","wow"]

Usage On Strings

str = "world"
// setup the string

str.prepend("hello ")
// update the variable and prepend the value to the start of the string

log str
// returns "hello world"

Last updated