p5.js concat() function
Last Updated :
22 Aug, 2023
The concat() function in p5.js is used to concatenate the two given arrays. This function is depreciated from future versions and uses First_array.concat(Second_array) instead.
Syntax:
concat(First_array, Second_array)
Parameters: This function accepts two parameters as mentioned above and described below:
- First_array: The first array will be concatenated with the second array.
- Second_array: The second array will be concatenated with the first array.
Return Value: It returns a new concatenated array. Below program illustrates the concat() function in p5.js:
Example: This example uses concat() function to concatenate two arrays.
javascript
function setup() {
createCanvas(500, 90);
}
function draw() {
background(220);
let Array1 = [ 'IT' , 'CSE' , 'ECE' ];
let Array2 = [ 'Civil' , 'Mechanical' ];
let Array3 = concat(Array1, Array2);
textSize(16);
fill(color( 'red' ));
text(& quot;New concatenated array is: & quot;
+ Array3, 50, 30);
}
|
Output:
Reference: https://p5js.org/reference/#/p5/concat
Share your thoughts in the comments
Please Login to comment...