Unit 3 · Module 1
The Host Idea
Language, host, and your code — telling them apart in any script you read
Three layers
A script is three layers: the language it’s written in, the host environment running it, and the developer’s own code.
The language
The grammar. const, function, =,
if, for. Looks the same everywhere the language
runs.
The host
The thing the script runs inside. Google Sheets. Airtable. The browser. Each host hands the script a pre-loaded set of objects — the “toys in the toy box” — that let it reach into that specific product.
Your code
Variable names, values passed in, logic. The only part the developer actually invents.
What the host’s objects are called
The host is the environment — Google, Airtable, the browser. The specific
objects the host hands the script (SpreadsheetApp,
base, document) have a name of their own:
host globals. That’s the term used in most JavaScript
documentation. Google’s own Apps Script docs call the same things
services — “the Spreadsheet Service” is the
collection of methods that hang off SpreadsheetApp. Different
word, same idea.
One line, three layers
A line of Google Apps Script:
Apps Script
const sheet = SpreadsheetApp.getActiveSpreadsheet(); | Piece | Layer | Renameable? |
|---|---|---|
const | Language | No — keyword |
sheet | Your code | Yes — anything |
= | Language | No |
SpreadsheetApp | Host global (Google) | No — Google’s name |
.getActiveSpreadsheet() | Host global (Google) | No — Google’s method |
Same pattern, different host
Airtable:
Airtable
let table = base.getTable("Orders"); let— languagetable— your namebase— host global (Airtable pre-loaded it).getTable("Orders")— host method;"Orders"is your value because it’s a real tab name in the base
Browser:
Browser
const button = document.getElementById("submit"); const— languagebutton— your namedocument— host global (the browser pre-loaded it).getElementById("submit")— host method;"submit"is your value
Three hosts, identical structure.