Google Sheets
Get the Last Rows / Columns of Data
Option A is to use sheet methods to get the coordinates of the last area of data, and then pull values by coordinates.
const dataRange = sheet.getDataRange();
const lastRow = sheet.getRange(dataRange.getLastRow(), dataRange.getColumn(), 1, dataRange.getNumColumns());
const lastRowVal = lastRow.getValues()[0];
Option B is probably less efficient; pull all data on the sheet into JS, and then return the last values with JS:
const mdDataArr = sheet.getDataRange().getValues();
const lastRowVal = mdDataArr[mdDataArr.length - 1];
Either of these approaches could easily be modified to return more than one row, just the last column, etc.
Get the very first sheet of a Spreadsheet Doc
const doc = SpreadsheetApp.getActiveSpreadsheet();
const firstSheet = doc.getSheets()[0];