In Excel 365 online, click on the Automate tab, then New Script to write Office Script code. It's language is TypeScript, which is a strongly typed version of JavaScript. After writing the Office Script, create a flow that uses the Excel Online (Business) Run Script connector to run the Office Script.

In the Run script connector, you specify the workbook that is running the script and which script to run, for example:

You can pass additional text information to and from scripts by adding additional properties in the main function, then there will additional boxes to complete in the connector and you'll be able to use what is returned in following connectors, for example:
function main(workbook: ExcelScript.Workbook, tablename:string):string[] {
// function content using input variable, i.e., tablename string
let values = workbook.getTable(tablename).getHeaderRowRange().getValues0 as string[][];
// return value matching type of main return, i.e., string array of header row
return values[0];
}