{"data":{"site":{"siteMetadata":{"title":"Refactor Academy | Code Courses","docsLocation":"https://github.com/hasura/gatsby-gitbook-boilerplate/tree/master/content"}},"mdx":{"fields":{"id":"1ad1e06a-206a-5fd3-bb20-1aef8d1bb9a0","title":"Understand Function in an Object","slug":"/function-in-an-object/understand-function-in-an-object"},"code":{"body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"Understand Function in an Object\",\n  \"metaTitle\": \"Function in an Object: Understand - JavaScript Fundamentals | Refactor Academy\",\n  \"metaDescription\": \"Let's see how to use a function within an object. This is part of Refactor Academy's JavaScript Fundamentals course.\"\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h1\", null, \"Function in an Object\"), mdx(\"p\", null, \"Data and functions organized within an object allows us to hold pieces of related information.\"), mdx(\"h1\", null, \"Object Syntax\"), mdx(\"p\", null, \"Functions have the same syntax when they are in an object except for how their name is declared. Instead of \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"let variableName =\"), \" objects use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"variableName:\"), \" to declare variables. This is true for functions and key value pairs.\"), mdx(\"p\", null, \"Using functions you write the object name followed by a period followed by the function name with parentheses and any arguments in those parentheses.\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-js\"\n  }), \"let aPersonObject = {\\n    name: 'Andrea',\\n    age: 39,\\n    country: 'USA',\\n    friendFunction: function(friend) {\\n        return 'Andrea and ' + friend + ' are friends!';\\n    }\\n}\\nconsole.log(aPersonObject.friendFunction('Alfred'));\\n\")));\n}\nMDXContent.isMDXComponent = true;"},"tableOfContents":{"items":[{"url":"#function-in-an-object","title":"Function in an Object"},{"url":"#object-syntax","title":"Object Syntax"}]},"parent":{"__typename":"File","relativePath":"function-in-an-object/understand-function-in-an-object.mdx"},"frontmatter":{"metaTitle":"Function in an Object: Understand - JavaScript Fundamentals | Refactor Academy","metaDescription":"Let's see how to use a function within an object. This is part of Refactor Academy's JavaScript Fundamentals course."}},"allMdx":{"edges":[{"node":{"fields":{"slug":"/arrays","title":"Arrays"}}},{"node":{"fields":{"slug":"/booleans","title":"Booleans"}}},{"node":{"fields":{"slug":"/course-overview","title":"Course Overview"}}},{"node":{"fields":{"slug":"/control-flow","title":"Control Flow"}}},{"node":{"fields":{"slug":"/function-in-an-object","title":"Function in an Object"}}},{"node":{"fields":{"slug":"/","title":"JavaScript Fundamentals"}}},{"node":{"fields":{"slug":"/functions","title":"Functions"}}},{"node":{"fields":{"slug":"/first-javascript-code","title":"First JavaScript Code"}}},{"node":{"fields":{"slug":"/javascript","title":"JavaScript"}}},{"node":{"fields":{"slug":"/intro-to-code","title":"Introduction to Code"}}},{"node":{"fields":{"slug":"/loops","title":"Loops"}}},{"node":{"fields":{"slug":"/numbers-and-math","title":"Numbers and Math"}}},{"node":{"fields":{"slug":"/objects","title":"Objects"}}},{"node":{"fields":{"slug":"/properties-and-methods","title":"Properties and Methods"}}},{"node":{"fields":{"slug":"/strings","title":"Strings"}}},{"node":{"fields":{"slug":"/variables-and-data-types","title":"Variables & Data Types"}}},{"node":{"fields":{"slug":"/tools","title":"Tools"}}},{"node":{"fields":{"slug":"/arrays/explore-arrays","title":"Explore Arrays"}}},{"node":{"fields":{"slug":"/arrays/understand-arrays","title":"Understand Arrays"}}},{"node":{"fields":{"slug":"/booleans/explore-booleans","title":"Explore Booleans"}}},{"node":{"fields":{"slug":"/booleans/understand-booleans","title":"Understand Booleans"}}},{"node":{"fields":{"slug":"/control-flow/explore-control-flow","title":"Explore Control Flow"}}},{"node":{"fields":{"slug":"/control-flow/understand-control-flow","title":"Understand Control Flow"}}},{"node":{"fields":{"slug":"/function-in-an-object/explore-function-in-an-object","title":"Explore Function in an Object"}}},{"node":{"fields":{"slug":"/function-in-an-object/understand-function-in-an-object","title":"Understand Function in an Object"}}},{"node":{"fields":{"slug":"/functions/explore-functions","title":"Explore Functions"}}},{"node":{"fields":{"slug":"/functions/understand-functions","title":"Understand Functions"}}},{"node":{"fields":{"slug":"/loops/explore-loops","title":"Explore Loops"}}},{"node":{"fields":{"slug":"/loops/understand-loops","title":"Understand Loops"}}},{"node":{"fields":{"slug":"/numbers-and-math/01-explore-numbers-and-math","title":"Explore Numbers and Math"}}},{"node":{"fields":{"slug":"/numbers-and-math/02-understand-numbers","title":"Understand Numbers"}}},{"node":{"fields":{"slug":"/numbers-and-math/understand-math","title":"Understand Math"}}},{"node":{"fields":{"slug":"/objects/explore-objects","title":"Explore Objects"}}},{"node":{"fields":{"slug":"/objects/understand-objects","title":"Understand Objects"}}},{"node":{"fields":{"slug":"/properties-and-methods/explore-properties-and-methods","title":"Explore Properties and Methods"}}},{"node":{"fields":{"slug":"/properties-and-methods/understand-properties-and-methods","title":"Understand Properties and Methods"}}},{"node":{"fields":{"slug":"/strings/explore-strings","title":"Explore Strings"}}},{"node":{"fields":{"slug":"/strings/understand-strings","title":"Understand Strings"}}},{"node":{"fields":{"slug":"/variables-and-data-types/explore-variables-and-data-types","title":"Explore Variables & Data Types"}}},{"node":{"fields":{"slug":"/variables-and-data-types/understand-variables-and-data-types","title":"Understand Variables & Data Types"}}}]}},"pageContext":{"isCreatedByStatefulCreatePages":false,"id":"1ad1e06a-206a-5fd3-bb20-1aef8d1bb9a0"}}