Skip to content
Related Articles

Related Articles

p5.js | getURLPath() Function

Improve Article
Save Article
Like Article
  • Last Updated : 17 Jan, 2020

The getURLPath() function is used to return the current URL path as an array, with each item being a portion of the URL path. This array can be traversed to access every portion of the path separately.



Parameters: This function does not accept any parameters.

Return Value: It returns an array of the path components.

Below example illustrates the getURLPath() function in p5.js:


function setup() {
  createCanvas(500, 200);
  // get the url path as array
  urlPathArray = getURLPath();
  text("The URL is:", 10, 20);
  text("The URL paths are: ", 10, 40);
  // loop through the array to display
  // the array items
  for (let i = 0; i < urlPathArray.length; i++) {
    text('- ' + urlPathArray[i], 10, i * 15 + 60);
  // display the array in the console


  • Displaying the contents of the array:
  • Viewing the array in the console:

Online editor:
Environment Setup:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!