p5.js splice() function Last Updated : 22 Aug, 2023 Comments Improve Suggest changes Like Article Like Report The splice() function in p5.js is used to insert values or array elements in the given array.Syntax: splice(Array, Values, Position) Parameters: This function accepts three parameters as mentioned above and described below: Array: This is a given array which is to be modified.Values: This is the values or an another array whose elements are to be inserted into the given array which are to modified.Position: This is the number of elements of the given array after which new values or elements of another array are to be inserted. Return Value: It returns a new modified array.Below programs illustrate the splice() function in p5.js:Example 1: This example uses splice() function to insert values or array elements in the given array. javascript function setup() { // Creating Canvas size createCanvas(500, 90); } function draw() { // Set the background color background(220); // Initializing the array let Array = [9, 6, 0, 22, 4, 1, 15]; // Initializing the value which are // to be inserted let Value = 5; // Initializing the position after // which insertion is done // counting is done from starting let Position = 5; // Calling to splice() function. let A = splice(Array, Value, Position); // Set the size of text textSize(16); // Set the text color fill(color('red')); // Getting new modified array text("New modified array is : " + A, 50, 30); } Output: Example 2: This example uses splice() function to insert values or array elements in the given array. javascript function setup() { // Creating Canvas size createCanvas(500, 90); } function draw() { // Set the background color background(220); // Initializing the array let Array = ['Ram', 'Geeta', 'Shita', 'Shyam']; // Initializing the value which are // to be inserted let Value = 'Geeks'; // Initializing the position after // which insertion is done // counting is done from starting let Position = 2; // Calling to splice() function. let A = splice(Array, Value, Position); // Set the size of text textSize(16); // Set the text color fill(color('red')); // Getting new modified array text("New modified array is : " + A, 50, 30); } Output: Example 3: This example uses splice() function to insert array elements into another array. javascript function setup() { // Creating Canvas size createCanvas(600, 90); } function draw() { // Set the background color background(220); // Initializing the array let Array = ['Ram', 'Geeta', 'Shita', 'Shyam']; // Initializing a new array whose elements are // to be inserted let Value = ['Geeks', 'GeeksforGeek']; // Initializing the position after // which insertion is done // counting is done from starting let Position = 2; // Calling to splice() function. let A = splice(Array, Value, Position); // Set the size of text textSize(16); // Set the text color fill(color('red')); // Getting new modified array text("New modified array is : " + A, 50, 30); } Output: Reference: https://p5js.org/reference/#/p5/splice Comment More infoAdvertise with us Next Article p5.js splice() function K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies JavaScript-p5.js Similar Reads p5.js split() function The split() function in p5.js is used to break the input string into pieces using a delimiter. This delimiter could be any string or symbol used between each piece of the input string. Syntax: split(String, Delimiter) Parameters: This function accepts two parameters which are described below: String 2 min read p5.js splitTokens() function The splitTokens() function in p5.js is used to break the input string into pieces of data using a delimiter. This delimiter could be any string or symbol used between each piece of the input string. Syntax:  splitTokens( string, delimiter ) Parameters: This function accepts two parameters as mentio 2 min read Node.js slice() function The slice() function is a string function of Node.js which is used to extract sub-string from a string. Syntax: string.slice( start, end ) Parameters: This function uses three parameters as mentioned above and described below: string: It holds the string content. The substring is extracted from this 1 min read p5.js shuffle() function The shuffle() function in p5.js is used to shuffle the order of given array elements. Syntax: shuffle(Array) Parameters: This function accepts a parameter Array whose elements are to be shuffled. Return Value: It returns the shuffled array. Below program illustrates the shuffle() function in p5.js: 2 min read p5.js subset() function The subset() function in p5.js is used to get the subset of the given array elements. This function extracts the elements from an existing array. Syntax: subset(Array, Start, Count) Parameters: This function accepts three parameters as mentioned above and described below: Array: This parameter hold 2 min read p5.js trim() function The trim() function in p5.js is used to remove whitespace characters and tab from the beginning and end of an input String. This function is also used to remove the carriage return and Unicode "nbsp" character. Syntax: trim(Strings) or trim(Array_of_Strings) Parameters: This function accepts a para 2 min read Node.js split() Function Splitting a string is one of the most widely used functions by the split() method, which splits a string into an array of substrings. This function belongs to the prototype in JavaScript and is applied in many kinds of activities like data parsing from files, extracting information from URLs, or tex 2 min read p5.js shorten() function The shorten() function in p5.js is used to decrease the number of elements of the given array by one. Syntax: shorten(Array) Parameters: This function accepts a parameter Array whose elements are to be shortened by one. Return Value: It returns the shortened array. Below program illustrates the shor 1 min read PHP array_splice() Function This inbuilt function of PHP is an advanced and extended version of array_slice() function, where we not only can remove elements from an array but can also add other elements to the array. The function generally replaces the existing element with elements from other arrays and returns an array of r 2 min read p5.js join() function The join() function in p5.js is used to join the input array of strings into a single string using separator. This separator might be any character which gets their position in between two strings of the input array. Syntax: join(Array, Separator) Parameters: This function accepts two parameters as 2 min read Like