Saturday, February 7, 2026
HomeLanguagesJavascriptp5.js getURLParams() Function

p5.js getURLParams() Function

The getURLParams() function is used to return the current URL parameters a JavaScript object, with each parameter as a separate member of the object.

Syntax:

getURLParams()

Parameters: This function does not accept any parameters.

Return Value: It returns an Object of the path parameters.

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

Example:




function setup() {
  createCanvas(500, 200);
  
  // get the url path as array
  urlParamsObject = getURLParams();
  
  textSize(16);
    10, 20);
  
  text("The URL parameters are: ", 10, 60);
  
  text("Type parameter: " + urlParamsObject["type"], 10, 80);
  text("Height parameter: " + urlParamsObject.height, 10, 100);
  text("Width parameter: " + urlParamsObject.width, 10, 120);
  
  // display the array in the console
  console.log(urlParamsObject);
}


Output:

  • Displaying the properties of the object:
    path-obj-display
  • Viewing the object in the console:
    path-obj-console

Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/

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

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!
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32493 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6864 POSTS0 COMMENTS
Nicole Veronica
11990 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12083 POSTS0 COMMENTS
Shaida Kate Naidoo
7000 POSTS0 COMMENTS
Ted Musemwa
7240 POSTS0 COMMENTS
Thapelo Manthata
6951 POSTS0 COMMENTS
Umr Jansen
6936 POSTS0 COMMENTS