p5.TableRow set() Method Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The set() method of p5.TableRow in p5.js is used to store the given value to the given column of the table. The column can be specified by its column ID or name. Syntax: set( column, value ) Parameters: This method accepts two parameters as mentioned above and described below: column: It is a String or Number that denotes the column name or ID of the column.value: It is a String or Number that specifies the value that has to be stored. The example below illustrates the set() method in p5.js: Example 1: javascript function setup() { createCanvas(500, 300); textSize(18); text("Click on the button to set " + "the values of the table", 20, 20); setBtn = createButton("Add Table Values"); setBtn.position(30, 40); setBtn.mouseClicked(setTableData); // Create the table table = new p5.Table(); // Add 5 columns and rows to the table for (let i = 0; i < 5; i++) { table.addColumn("Column " + i); table.addRow(); } } function setTableData() { for (let r = 0; r < 5; r++) { for (let c = 0; c < 3; c++) { // Get the row of the table let tableRow = table.rows[r]; // Set the value at the given // column of the row tableRow.set(c, r + "::" + c); } } showTable(); } function showTable() { clear(); text("The values of the table are " + "added using the set() method", 20, 20); // Show all the columns present for (let c = 0; c < 3; c++) { text(table.columns[c], 20 + 100 * c, 80); } // Show all the rows currently // present in the table for (let r = 0; r < 5; r++) { for (let c = 0; c < 3; c++) { text(table.getString(r, c), 20 + 100 * c, 120 + 20 * r); } } } Output: Example 2: javascript function setup() { createCanvas(500, 300); textSize(18); changeBtn = createButton("Modify Table"); changeBtn.position(30, 40); changeBtn.mouseClicked(modifyTable); // Create the table table = new p5.Table(); // Add 5 columns and rows to the table for (let i = 0; i < 5; i++) { table.addColumn("Column " + i); table.addRow(); } setTableData(); // Display the table showTable(); } function setTableData() { for (let r = 0; r < 5; r++) { for (let c = 0; c < 5; c++) { // Set the value at the given // column and row of the table table.set(r, c, 0 + " " + 0); } } showTable(); } function modifyTable() { for (let r = 0; r < 5; r++) { // Get the row of the table let tableRow = table.rows[r]; for (let c = 0; c < 5; c++) { // If the index of the table is // a diagonal, set it to "XX" if (r == c) tableRow.set(c, "XX"); if (r + c == 4) tableRow.set(c, "YY"); } } showTable(); } function showTable() { clear(); text("The values are added and " + "modified using the set() method", 20, 20); // Show all the rows currently // present in the table for (let r = 0; r < 5; r++) { for (let c = 0; c < 5; c++) { text(table.getString(r, c), 20 + 80 * c, 80 + 20 * r); } } } Output: Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/javascript/p5-js-soundfile-object-installation-and-methods/Reference: https://p5js.org/reference/#/p5.TableRow/set Comment More infoAdvertise with us Next Article p5.Table set() Method S sayantanm19 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-p5.js Similar Reads p5.TableRow setNum() Method The setNum() method of p5.TableRow in p5.js is used to store the given Float value to the given column of the table. The column can be specified by its column ID or column name.Syntax:setNum( column, value )Parameters: This method accepts two parameters as mentioned above and described below: column 2 min read p5.TableRow setNum() Method The setNum() method of p5.TableRow in p5.js is used to store the given Float value to the given column of the table. The column can be specified by its column ID or column name.Syntax:setNum( column, value )Parameters: This method accepts two parameters as mentioned above and described below: column 2 min read p5.Table set() Method The set() method of p5.Table in p5.js is used to store the given value to the given row and column of the table. The row can be specified by the row ID and the column can be specified by its column ID or name. Syntax: set( row, column, value ) Parameters: This function accepts three parameters as me 3 min read p5.Table set() Method The set() method of p5.Table in p5.js is used to store the given value to the given row and column of the table. The row can be specified by the row ID and the column can be specified by its column ID or name. Syntax: set( row, column, value ) Parameters: This function accepts three parameters as me 3 min read p5.TableRow setString() Method The setString() method of p5.TableRow in p5.js is used to store the given String value to the given column of the table row. The column can be specified by its column ID or column name. Syntax: setString( column, value ) Parameters: This method accepts two parameters as mentioned above and described 3 min read p5.TableRow setString() Method The setString() method of p5.TableRow in p5.js is used to store the given String value to the given column of the table row. The column can be specified by its column ID or column name. Syntax: setString( column, value ) Parameters: This method accepts two parameters as mentioned above and described 3 min read Like