{"id":15381,"date":"2023-07-28T09:00:00","date_gmt":"2023-07-28T00:00:00","guid":{"rendered":"https:\/\/www.autooffice.co.kr\/blog\/2023\/07\/28\/apps-script-blog-working-with-objects\/"},"modified":"2025-09-15T18:29:07","modified_gmt":"2025-09-15T09:29:07","slug":"apps-script-blog-working-with-objects","status":"publish","type":"post","link":"https:\/\/www.autooffice.co.kr\/en\/blog\/2023\/07\/28\/apps-script-blog-working-with-objects\/","title":{"rendered":"Apps Script Blog &#8211; Working with Objects"},"content":{"rendered":"<p>This post is a corrected post after AI explains the code included in the book <a title=\"\" href=\"https:\/\/www.autooffice.io\/content\/ebizbooks-apps-script\" target=\"_blank\" rel=\"noopener\">&#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>Table of Contents<\/h2>\n<ul>\n<li><a href=\"#summary\">Summary<\/a><\/li>\n<li><a href=\"#code\">Code<\/a><\/li>\n<li><a href=\"#explanation\">Code Explanation<\/a><\/li>\n<li><a href=\"#example\">Example<\/a><\/li>\n<li><a href=\"#ai-prompt\">AI Prompt<\/a><\/li>\n<\/ul>\n<h2 id=\"summary\">Summary<\/h2>\n<p>In this blog post, we will explore how to work with objects in Apps Script. Objects are a fundamental data type in JavaScript and are used to store key-value pairs. We will learn how to define and access object properties, as well as how to create and manipulate objects in our Apps Script projects.<\/p>\n<h2 id=\"code\">Code<\/h2>\n<pre><code>let obj = {\n  key1: 'value1',\n  key2: 'value2', \n  key3: 'value3'\n}<\/code><\/pre>\n<h2 id=\"explanation\">Code Explanation<\/h2>\n<p>Here, we have created an object named <code>obj<\/code> with three key-value pairs. Each key represents a property name, and its corresponding value represents the value of that property. In this example, we have three properties: <code>key1<\/code>, <code>key2<\/code>, and <code>key3<\/code>, with their respective values <code>'value1'<\/code>, <code>'value2'<\/code>, and <code>'value3'<\/code>.<\/p>\n<h2 id=\"example\">Example<\/h2>\n<p>Let&#8217;s say we want to access the value of <code>key2<\/code> in our <code>obj<\/code> object. We can do so by using the dot notation:<\/p>\n<pre><code>console.log(obj.key2); \/\/ Output: 'value2'<\/code><\/pre>\n<p><span style=\"color: #ff3366;\">AI generated example successfully. It covers over the code explained here <\/span><\/p>\n<h2 id=\"ai-prompt\">AI Prompt<\/h2>\n<p><s>Generate the following code using the given prompt:<\/s><\/p>\n<p><span style=\"color: #ff3366;\">Write code to create an object with three key-value pairs. Name the object &#8216;obj&#8217; and assign the keys as &#8216;key1&#8217;, &#8216;key2&#8217;, and &#8216;key3&#8217;, with their respective values as &#8216;value1&#8217;, &#8216;value2&#8217;, and &#8216;value3&#8217;. <\/span><\/p>\n<pre><code>let obj = {\n  key1: 'value1',\n  key2: 'value2', \n  key3: 'value3'\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, we will explore how to work with objects in Apps Script. Objects are a fundamental data type in JavaScript and are used to store key-value pairs. We will learn how to define and access object properties, as well as how to create and manipulate objects in our Apps Script projects.<\/p>\n","protected":false},"author":1,"featured_media":15389,"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,7],"class_list":["post-15381","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spreadsheet","category-apps-script","tag-ai-assisted","tag-script","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\/15381","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=15381"}],"version-history":[{"count":3,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts\/15381\/revisions"}],"predecessor-version":[{"id":17214,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/posts\/15381\/revisions\/17214"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/media\/15389"}],"wp:attachment":[{"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/media?parent=15381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/categories?post=15381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.autooffice.co.kr\/en\/wp-json\/wp\/v2\/tags?post=15381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}