Wednesday, July 3, 2024
HomeLanguagesJavascriptp5.js concat() function

p5.js concat() function

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() {
  
    // 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(& quot;New concatenated array is: & quot;
    + Array3, 50, 30);
}


Output: 

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Shaida Kate Naidoo
am passionate about learning the latest technologies available to developers in either a Front End or Back End capacity. I enjoy creating applications that are well designed and responsive, in addition to being user friendly. I thrive in fast paced environments. With a diverse educational and work experience background, I excel at collaborating with teams both local and international. A versatile developer with interests in Software Development and Software Engineering. I consider myself to be adaptable and a self motivated learner. I am interested in new programming technologies, and continuous self improvement.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments