{"id":15382,"date":"2023-07-28T09:00:00","date_gmt":"2023-07-28T00:00:00","guid":{"rendered":"https:\/\/www.autooffice.co.kr\/blog\/2023\/07\/28\/exploring-objects-in-apps-script\/"},"modified":"2025-09-15T18:29:47","modified_gmt":"2025-09-15T09:29:47","slug":"exploring-objects-in-apps-script","status":"publish","type":"post","link":"https:\/\/www.autooffice.co.kr\/en\/blog\/2023\/07\/28\/exploring-objects-in-apps-script\/","title":{"rendered":"Exploring Objects in Apps Script"},"content":{"rendered":"<p>This post is a corrected post after AI explains the code included in the book <a href=\"https:\/\/www.autooffice.io\/content\/ebizbooks-apps-script\" target=\"_blank\" rel=\"noopener\" title=\"\">&#8220;Google Apps Script 101: Building Work Automation For Free&#8221;<\/a>. Added a <s>strikethrough<\/s> when editing what AI has written, and added <span style=\"color: #ff3366;\">color<\/span> when edited by author<\/p>\n<h2>Summary<\/h2>\n<p>In this blog post, we will explore how to work with objects in Apps Script. We will learn how to access object properties using dot notation and square brackets, as well as dynamically accessing properties using variables.<\/p>\n<h2 id=\"code\">Code<\/h2>\n<pre><code>function myObject() {\n  let obj = {\n    key1: 'value1',\n    key2: 'value2',\n    key3: 'value3'\n  }\n\n  Logger.log(obj.key1)\n  Logger.log(obj['key1'])\n\n  let keyName = 'key1'\n  Logger.log(obj[keyName])\n}<\/code><\/pre>\n<h2 id=\"explanation\">Code Explanation<\/h2>\n<p>The code declares a function named <code>myObject<\/code>. Inside the function, an object <code>obj<\/code> is created with three key-value pairs.<\/p>\n<p>The <code>Logger.log<\/code> statements are used to print the value of the <code>key1<\/code> property of the <code>obj<\/code> object. The property value can be accessed using both dot notation and square brackets.<\/p>\n<p>A variable <code>keyName<\/code> is declared and assigned the value <code>'key1'<\/code>. The value of the <code>keyName<\/code> variable is then used to access the <code>key1<\/code> property of the <code>obj<\/code> object.<\/p>\n<h2 id=\"example\">Example<\/h2>\n<p>When the <code>myObject<\/code> function is executed, the following values will be logged in the Apps Script Logger:<\/p>\n<pre><code>value1\nvalue1\nvalue1<\/code><\/pre>\n<h2 id=\"ai-prompt\">AI Prompt<\/h2>\n<p>Write a function that creates an object with three key-value pairs. Log the value of the first key using both dot notation and square brackets. Use a variable to dynamically access the value of the first key.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, we will explore how to work with objects in Apps Script. We will learn how to access object properties using dot notation and square brackets, as well as dynamically accessing properties using variables.<\/p>\n","protected":false},"author":1,"featured_media":15394,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[5,118],"tags":[512,69,523,7],"class_list":["post-15382","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spreadsheet","category-apps-script","tag-ai-assisted","tag-script","tag-object","tag-spreadsheet"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"en","enabled_languages":["ko","en"],"languages":{"ko":{"title":true,"content":true,"excerpt":true},"en":{"title":true,"content":true,"excerpt":true}}},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts\/15382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/comments?post=15382"}],"version-history":[{"count":5,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts\/15382\/revisions"}],"predecessor-version":[{"id":17215,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts\/15382\/revisions\/17215"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/media\/15394"}],"wp:attachment":[{"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/media?parent=15382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/categories?post=15382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/tags?post=15382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}