Basics
What works in the Apps Script V8 runtime
Apps Script runs modern V8 JavaScript on Google servers, without browser DOM globals, Node modules, or background timers.
1 of 5
Modern JavaScript syntax works on Google servers
Apps Script executes server files (.gs) on the V8 JavaScript engine, the same engine inside Chrome and Node.js. Google retired the older Rhino engine in January 2026, so new and maintained projects use V8.
Standard ECMAScript features work directly in Code.gs: const and let, arrow functions, template literals, destructuring, rest and spread syntax, Map, Set, classes, optional chaining (?.), nullish coalescing (??), regular expression named capture groups, and Intl formatters.
function countRequestsByDepartment() {
/** @type {Array<[string, string, number | null]>} */
const rows = [
['R-101', 'Finance', 120],
['R-102', 'Operations', null],
['R-103', 'Finance', 80],
];
/** @type {Map<string, { count: number, total: number }>} */
const totals = new Map();
for (const [, department, rawAmount] of rows) {
const amount = rawAmount ?? 0;
const current = totals.get(department) ?? { count: 0, total: 0 };
totals.set(department, {
count: current.count + 1,
total: current.total + amount,
});
}
for (const [department, summary] of totals) {
Logger.log(department + ': ' + summary.count + ' requests, $' + summary.total);
}
} 2 of 5
What V8 in Apps Script does not include
A JavaScript engine provides language syntax and standard objects such as Array and Math. The host environment provides input, output, networking, and timers. Apps Script supplies Google Workspace globals instead of browser or Node.js APIs.
- No browser DOM: window, document, localStorage, and navigator do not exist in .gs files. They exist only inside HTML files served through HtmlService.
- No fetch or URL: use UrlFetchApp.fetch() for HTTP requests instead of browser fetch().
- No Node.js built-ins: process, Buffer, fs, path, crypto, and require() do not exist. Use Utilities for Base64, digests, HMAC signatures, UUIDs, and ZIP archives.
- No ES modules in the runtime: import and export statements fail in .gs files. If you write modules locally in TypeScript, compile or strip module syntax before pushing with clasp.
- No event-loop timers: setTimeout and setInterval are absent. Use Utilities.sleep(milliseconds) for short pauses up to 5 minutes, or ScriptApp time-driven triggers for later runs.
3 of 5
Apps Script service calls block until they finish
Every built-in Apps Script call, such as range.getValues(), GmailApp.sendEmail(), or UrlFetchApp.fetch(), runs synchronously. The next line of your function does not start until Google returns the result.
V8 accepts the async and await keywords because they are part of JavaScript syntax, and Promise callbacks run on the microtask queue. That syntax does not make SpreadsheetApp or UrlFetchApp run in parallel. Worse, if a trigger handler or custom function is marked async and awaits a Promise that has not settled, Apps Script can end the execution before the continuation runs.
When you need parallel HTTP requests in a single run, pass an array of request objects to UrlFetchApp.fetchAll(requests). Google sends those requests concurrently and returns the responses in the same order.
5 of 5
A trailing underscore hides internal helpers
In Apps Script, ending a function name with an underscore, such as normalizeHeader_(text), marks that function as private to the project.
Functions whose names end in _ do not appear in the editor Run dropdown, cannot be imported as Google Sheets macros, and are hidden from consumers when you publish the project as an Apps Script library. Other files inside the same project can still call them normally.
Remember
The short version
- Apps Script runs on V8, so const, arrow functions, Map, Set, optional chaining, and ?? all work in .gs files.
- Browser and Node globals such as window, fetch, URL, Buffer, setTimeout, and import/export do not exist on the server.
- Built-in service calls are synchronous; use UrlFetchApp.fetchAll() when you need concurrent HTTP requests.
- All .gs files share one global scope, and top-level const or let values initialize in sidebar file order.
- End helper names with an underscore (helper_()) to hide them from the Run menu and library consumers.
Keep going
Put it to work
- Task guide Import data from a web API into Sheets
Pull a seven-day weather forecast from the free Open-Meteo API into a practice spreadsheet. The script checks the response and writes only cells A1:C12 of the Forecast tab, with the source and license links below the data.
- Task guide Write a custom function in Google Sheets
Write your own formula for Google Sheets. This one converts Celsius to Fahrenheit, works on one cell or a whole range, and shows a clear message when a cell holds text instead of a number.
- Basics Run your first Apps Script function
Your first script, from opening the editor to reading its output. You replace the starter function, save, click Run, and read what Logger.log printed in the Execution log.
- Basics Common Apps Script errors and what they mean
Apps Script error messages say what failed, for example TypeError: Cannot read properties of null (reading 'getRange') or ReferenceError. Find the exact message below for its cause and fix.
- Basics Google Apps Script quotas and limits
Google caps how long one run may take and how much your scripts may do in a day. Knowing the caps changes how you write anything that touches a lot of rows.
- Book chapter Extract text with regular expressions
Clean copied Workspace text, extract fields with V8 RegExp named capture groups and matchAll, and stamp records with UUIDs and SHA-256 digests.