Google Apps Script는 사용자 데이터, 기타 Google 시스템, 외부 시스템과 상호작용하기 위한 30개 이상의 기본 제공 서비스를 제공합니다. 이러한 서비스는 JavaScript의 표준 Math 객체와 유사한 전역 객체로 제공됩니다. 예를 들어 Math가 random()과 같은 메서드와 PI과 같은 상수를 제공하는 것처럼 Apps Script의 스프레드시트 서비스는 openById(id)과 같은 메서드, Range과 같은 클래스 (하위 객체), DataValidationCriteria과 같은 열거형을 제공합니다.
Google Workspace 제품을 제어하는 서비스의 참조 문서는 이 사이트의 사이드바에 있는 '참조' 헤더 아래의 'Google Workspace 서비스' 섹션에 수집되어 있습니다. 유틸리티 서비스 (사용자 인터페이스 생성, XML 파싱, 로그 데이터 작성 등)는 '스크립트 서비스' 섹션에 수집됩니다.
최신 JavaScript 기능
Apps Script는 최신 V8 런타임과 Mozilla의 Rhino JavaScript 인터프리터로 구동되는 이전 런타임의 두 가지 JavaScript 런타임을 지원합니다.
스크립트 편집기는 스크립트의 현재 컨텍스트에서 유효한 전역 객체와 메서드, 열거형을 표시하는 '콘텐츠 지원' 기능(일반적으로 '자동 완성'이라고 함)을 제공합니다. Apps Script 클래스를 반환하는 전역 객체, enum 또는 메서드 호출 뒤에 마침표를 입력하면 자동 완성 제안이 자동으로 표시됩니다. 예를 들면 다음과 같습니다.
전역 객체의 전체 이름을 입력하거나 자동 완성에서 선택한 다음 . (마침표)를 입력하면 해당 클래스의 모든 메서드와 enum이 표시됩니다.
GmailApp.sendEmail('claire@example.com','Subject line','This is the body.');
메서드가 다른 Apps Script 클래스를 반환하는 경우 한 줄에 메서드 호출을 연결할 수 있습니다. (반환 유형은 자동 완성 및 메서드의 참조 문서에 모두 표시됩니다.) 예를 들어 DocumentApp.create() 메서드는 Document을 반환하므로 다음 두 코드 섹션은 동일합니다.
모든 서비스에는 전역 객체로 최상위 수준에서 액세스할 수 없는 하나 이상의 하위 클래스가 포함됩니다. Date와 같은 표준 JavaScript 클래스와 마찬가지로 new 키워드를 사용하여 이러한 클래스를 생성할 수는 없습니다. 반환하는 메서드를 호출해야만 하위 클래스에 액세스할 수 있습니다. 특정 클래스에 액세스하는 방법을 잘 모르는 경우 서비스의 참조 문서 루트 페이지를 방문하여 원하는 클래스를 반환하는 메서드를 찾으세요.
인터페이스 처리
일부 서비스에는 참조 문서에서 '인터페이스'로 라벨이 지정된 특수 클래스가 포함되어 있습니다. 이는 미리 정확한 유형을 확인할 수 없는 메서드의 반환 유형으로 사용되는 일반 클래스입니다. 예를 들어 문서 서비스 메서드 Body.getChild(childIndex)는 일반 Element 객체를 반환합니다.
Element는 다른 클래스(Paragraph 또는 Table일 수 있음)를 나타내는 인터페이스입니다. 인터페이스 객체는 자체적으로 유용한 경우가 거의 없습니다. 대신 일반적으로 Element.asParagraph()과 같은 메서드를 호출하여 객체를 정확한 클래스로 다시 변환하려고 합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eGoogle Apps Script offers 30+ built-in services for interacting with Google and external systems, accessible as global objects similar to JavaScript's \u003ccode\u003eMath\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eApps Script supports modern ECMAScript syntax and features with the V8 runtime, which is recommended over the older Rhino runtime.\u003c/p\u003e\n"],["\u003cp\u003eServices provide global objects like \u003ccode\u003eGmailApp\u003c/code\u003e or \u003ccode\u003eSpreadsheetApp\u003c/code\u003e to access methods for interacting with specific Google products.\u003c/p\u003e\n"],["\u003cp\u003eChild classes like \u003ccode\u003eRange\u003c/code\u003e or \u003ccode\u003eDocument\u003c/code\u003e are accessed by calling methods of their parent global objects, enabling chained method calls for efficiency.\u003c/p\u003e\n"],["\u003cp\u003eEnums, such as \u003ccode\u003eDriveApp.Access\u003c/code\u003e, provide named values for specific functionalities within services like Drive.\u003c/p\u003e\n"]]],[],null,["# Built-in Google Services\n\nGoogle Apps Script provides more than 30 built-in services for interacting with\nuser data, other Google systems, and external systems. These services are\nprovided as global objects akin to JavaScript's standard\n[`Math`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math)\nobject. For example, just as `Math` offers methods like `random()` and\nconstants like `PI`, Apps Script's\n[Spreadsheet service](/apps-script/reference/spreadsheet) offers methods like\n[`openById(id)`](/apps-script/reference/spreadsheet/spreadsheet-app#openById(String)),\nclasses (child objects) like\n[`Range`](/apps-script/reference/spreadsheet/range), and enums like\n[`DataValidationCriteria`](/apps-script/reference/spreadsheet/data-validation-criteria).\n\nThe reference documentation for services that control\nGoogle Workspace products are collected in the\n\"Google Workspace Services\" section under the\n\"Reference\" header in the sidebar of this site. Utility services (for things\nlike creating user interfaces, parsing XML, or writing log data) are collected\nin the \"Script Services\" section.\n\nModern JavaScript features\n--------------------------\n\nApps Script supports two JavaScript runtimes: the modern\n[**V8**](https://v8.dev/) runtime and an older one powered by Mozilla's\n[**Rhino JavaScript interpreter**](https://en.wikipedia.org/wiki/Rhino_(JavaScript_engine)).\n\nThe [V8 runtime](/apps-script/guides/v8-runtime) supports modern\n[ECMAScript](https://en.wikipedia.org/wiki/ECMAScript) syntax and features.\nThe Rhino runtime is based on the older\n[JavaScript 1.6](https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.6)\nstandard, plus a few features from\n[1.7](https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.7) and\n[1.8](https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.8).\nYou can [freely choose which runtime](/apps-script/guides/v8-runtime#enabling_the_v8_runtime)\nto use with your script, but the V8 runtime is strongly recommended.\n\nEach runtime supports JavaScript classes and objects that are available to your\nscript in addition to the built-in\nand [advanced Google services](/apps-script/guides/services/advanced). Your\nscripts can use common objects like\n[`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array),\n[`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date),\n[`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp),\n[and so forth](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference),\nas well as the\n[`Math`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math) and\n[`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\nglobal objects.\n| **Note:** Because Apps Script code runs on Google's servers (with the exception of [HTML-service](/apps-script/guides/html) pages), browser-based JavaScript features like DOM manipulation or the [`Window`](https://developer.mozilla.org/en-US/docs/Web/API/Window) API are not available in Apps Script.\n\nUsing autocomplete\n------------------\n\nThe script editor provides a \"content assist\" feature, more commonly called\n\"autocomplete,\" which reveals the global objects as well as methods and enums\nthat are valid in the script's current context. Autocomplete suggestions appear\nautomatically whenever you type a period after a global object, enum, or method\ncall that returns an Apps Script class. For example:\n\n- If you type the full name of a global object or select one from autocomplete, then type `.` (a period), you will see all methods and enums for that class.\n- If you type a few characters, you'll see all valid suggestions that begin with those characters.\n\nUnderstanding global objects\n----------------------------\n\nEach service provides at least one global (top-level) object; for example,\nthe [Gmail service](/apps-script/reference/gmail) is accessed solely from\nthe [`GmailApp`](/apps-script/reference/gmail/gmail-app) object. Some services\nprovide multiple global objects; for example, the\n[Base service](/apps-script/reference/base) includes four global objects:\n[`Browser`](/apps-script/reference/base/browser),\n[`Logger`](/apps-script/reference/base/logger),\n[`MimeType`](/apps-script/reference/base/mime-type), and\n[`Session`](/apps-script/reference/base/session).\n\nCalling methods\n---------------\n\nThe global objects of nearly all built-in or\n[advanced services](/apps-script/guides/services/advanced) include methods that\nreturn data or an Apps Script class. Scripts make method calls in this format: \n\n GlobalObjectName.methodName(argument1, argument2, ..., argumentN);\n\nFor example, a script can send an email by calling the\n[`sendEmail(recipient, subject, body)`](/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String))\nmethod of the Gmail service like so: \n\n GmailApp.sendEmail('claire@example.com', 'Subject line', 'This is the body.');\n\nIf a method returns another Apps Script class, you can chain method calls on one\nline. (Return types are shown both in autocomplete and in a method's reference\ndocumentation.) For example, the method\n[`DocumentApp.create()`](/apps-script/reference/document/document-app#create(String))\nreturns a [`Document`](/apps-script/reference/document/document); thus, the\nfollowing two sections of code are equivalent: \n\n var doc = DocumentApp.create('New document');\n var body = doc.getTab('t.0').asDocumentTab().getBody();\n body.appendParagraph('New paragraph.');\n\n // Same result as above.\n DocumentApp.create('New document').getTab('t.0').asDocumentTab().getBody()\n .appendParagraph('New paragraph.');\n\nAccessing child classes\n-----------------------\n\nEvery service includes one or more child classes that cannot be accessed from\nthe top level as a global object can. You cannot use the `new` keyword to\nconstruct these classes, as you can with standard JavaScript classes like\n[`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date);\nyou can only access a child class by calling a method that returns it. If you're\nnot sure how to access a certain class, visit the root page for the service's\nreference documentation and look for a method that returns the class you want.\n\nDealing with interfaces\n-----------------------\n\nA handful of services include special classes that are labeled as \"interfaces\"\nin the reference documentation. These are generic classes used as return types\nfor methods that cannot determine the precise type in advance; for example,\nthe [Document service](/apps-script/reference/document) method\n[`Body.getChild(childIndex)`](/apps-script/reference/document/body#getChild(Integer))\nreturns a generic [`Element`](/apps-script/reference/document/element) object.\n`Element` is an interface that represents some other class, possibly a\n[`Paragraph`](/apps-script/reference/document/paragraph) or\n[`Table`](/apps-script/reference/document/table). Interface objects are rarely\nuseful on their own; instead, you usually want to call a method like\n[`Element.asParagraph()`](/apps-script/reference/document/element#asParagraph())\nto cast the object back to a precise class.\n\nWorking with enums\n------------------\n\nMost services include a few enums (enumerated types) of named values. For\nexample, the [Drive service](/apps-script/reference/drive) uses the enums\n[`Access`](/apps-script/reference/drive/access) and\n[`Permission`](/apps-script/reference/drive/permission) to determine which users\nhave access to a file or folder. In almost all cases, you access these enums\nfrom the global object. For example, a call to the method\n[`Folder.setSharing(accessType, permissionType)`](/apps-script/reference/drive/folder#setSharing(Access,Permission))\nlooks like this: \n\n // Creates a folder that anyone on the Internet can read from and write to. (Domain administrators can\n // prohibit this setting for Google Workspace users.)\n var folder = DriveApp.createFolder('Shared Folder');\n folder.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT);"]]