p5.js | concat() function

The concat() function in p5.js is used to concatenates the two given arrays. This function is depreciated from future versions and use 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 which will be concatened with second array.
  • Second_array: The second array which will be concatened with first array.

Return Value: It returns a new concatened array.

Below program illustrates the concat() function in p5.js:

Example: This example uses concat() function to concatenate two arrays.

filter_none

edit
close

play_arrow

link
brightness_4
code

function setup() { 
   
    // Creating Canvas size
    createCanvas(500, 90); 
   
function draw() { 
       
    // Set the background color 
    background(220); 
       
    // Initializing the arrays
    let Array1 = ['IT', 'CSE', 'ECE'];
    let Array2 = ['Civil', 'Mechanical'];
     
    // Calling to concat() function.
    let Array3 = concat(Array1, Array2);
       
    // Set the size of text 
    textSize(16); 
       
    // Set the text color 
    fill(color('red')); 
     
    // Getting new concatenated array
    text("New concatenated array is : " 
            + Array3, 50, 30);

chevron_right


Output:

Reference: https://p5js.org/reference/#/p5/concat



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.