{
    "componentChunkName": "component---src-components-layout-mdx-layout-tsx",
    "path": "/language/from-javascript",
    "result": {"data":{"site":{"siteMetadata":{"title":"Toit documentation"}},"mdx":{"body":"const _excluded = [\"components\"];\n\nfunction _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }\n\nfunction _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }\n\nfunction _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nconst _frontmatter = {};\nconst layoutProps = {\n  _frontmatter\n};\nconst MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  let {\n    components\n  } = _ref,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h1\", {\n    \"id\": \"toit-for-javascripters\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h1\",\n    \"href\": \"#toit-for-javascripters\",\n    \"aria-label\": \"toit for javascripters permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Toit for JavaScripters\"), mdx(\"p\", null, \"For JavaScript and TypeScript programmers who already know functions, objects,\\nand asynchronous code. This page highlights assumptions to revisit when moving\\nto Toit. For the full language introduction, read\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/toitversus\"\n  }, \"Toit for programmers\"), \", which explains each feature directly\\nand draws comparisons with C/C++, JavaScript, Python, and Java/Kotlin.\"), mdx(\"p\", null, \"Each Toit example is a complete program you can run using the\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/beginner#1-run-your-first-program\"\n  }, \"local setup\"), \".\"), mdx(\"span\", {\n    id: \"calls-do-not-produce-function-references\"\n  }), mdx(\"h2\", {\n    \"id\": \"calling-functions-and-methods\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#calling-functions-and-methods\",\n    \"aria-label\": \"calling functions and methods permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Calling functions and methods\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"console.log(value)\"), \" becomes \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"print value\"), \": spaces separate the arguments.\\nWhen one call supplies an argument to another, group it with parentheses:\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"print (int.parse \\\"42\\\")\"), \".\"), mdx(\"p\", null, \"A zero-argument method is called by naming it. In this example, \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"name.trim\"), \"\\ncalls \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"trim\"), \" and returns a string:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  name := \\\" Ada \\\"\\n  print name.trim\\n\")), mdx(\"p\", null, \"This prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Ada\"), \". Toit uses indentation to group statements, with two spaces\\nper level. Names for variables and functions use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"kebab-case\"), \".\"), mdx(\"h2\", {\n    \"id\": \"variables-and-final-bindings\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#variables-and-final-bindings\",\n    \"aria-label\": \"variables and final bindings permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Variables and final bindings\"), mdx(\"p\", null, \"Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \":=\"), \" to introduce a local variable and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"=\"), \" to reassign it. Toit normally\\nuses mutable locals, even when a particular variable is only assigned once.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  count := 1\\n  count++\\n  print count  // Prints 2.\\n\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"::=\"), \" declares a final binding, like JavaScript's \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"const\"), \": the binding cannot\\nbe reassigned, but the object can still change. Prefer final bindings for fields\\nand globals when reassignment is unnecessary. A common field declaration is\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"name/string\"), \", which also makes the field final; we will use it in the class\\nexample below.\"), mdx(\"h2\", {\n    \"id\": \"named-arguments\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#named-arguments\",\n    \"aria-label\": \"named arguments permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Named arguments\"), mdx(\"p\", null, \"Named arguments are part of a function's signature and its calls. They are\\nwritten with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"--\"), \"; they are not properties of an options object:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"greet name --greeting=\\\"Hello\\\":\\n  print \\\"$greeting $name\\\"\\n\\nmain:\\n  greet \\\"Ada\\\"\\n  greet \\\"Grace\\\" --greeting=\\\"Welcome\\\"\\n\")), mdx(\"p\", null, \"This prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Hello Ada\"), \", then \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Welcome Grace\"), \". The default is used when the\\nargument is omitted. Positional parameters can have defaults too.\\nSee \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/syntax\"\n  }, \"syntax\"), \" for more call examples.\"), mdx(\"h2\", {\n    \"id\": \"strings-interpolate-with-\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#strings-interpolate-with-\",\n    \"aria-label\": \"strings interpolate with  permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Strings interpolate with \", mdx(\"inlineCode\", {\n    parentName: \"h2\"\n  }, \"$\")), mdx(\"p\", null, \"Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"\\\"Hello $name\\\"\"), \" or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"\\\"Hello $(name.trim)\\\"\"), \" in place of a template literal's\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"${name}\"), \" expression. Toit uses ordinary double quotes for interpolated strings.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  name := \\\"Ada\\\"\\n  print \\\"Hello $name\\\"             // Prints Hello Ada.\\n  print \\\"Name length: $name.size\\\"  // Prints Name length: 3.\\n\")), mdx(\"p\", null, \"Dot access and indexing are included in the interpolation. Parentheses delimit\\nit: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"\\\"$(name).size\\\"\"), \" produces \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Ada.size\"), \". See the\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/toitversus#string-interpolation\"\n  }, \"interpolation examples\"), \"\\nfor an expandable collection covering boundaries, expressions, and formatting.\"), mdx(\"h2\", {\n    \"id\": \"blocks-are-not-arrow-functions\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#blocks-are-not-arrow-functions\",\n    \"aria-label\": \"blocks are not arrow functions permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Blocks are not arrow functions\"), mdx(\"p\", null, \"The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \":\"), \" in \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"values.do: |value|\"), \" introduces a block. Like a callback passed to\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"forEach\"), \", it runs for each element, but its control flow is different:\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"return\"), \" leaves the enclosing function, not just the iteration.\"), mdx(\"p\", null, \"The last expression gives a block its value. Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"continue.do\"), \" to skip to the\\nnext iteration. Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"::\"), \" for a lambda that can be stored or returned. A lambda\\nuses its final expression as its result and cannot contain an explicit \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"return\"), \".\\nThis distinction lets library iteration behave like a loop while supporting\\ncallbacks with a longer lifetime.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"find-long-name names:\\n  names.do: |name|\\n    if name.size > 4:\\n      return name\\n  return null\\n\\nmain:\\n  print (find-long-name [\\\"Ada\\\", \\\"Grace\\\", \\\"Linus\\\"])\\n\")), mdx(\"p\", null, \"This prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Grace\"), \". This exit from the surrounding function is called a\\n\", mdx(\"em\", {\n    parentName: \"p\"\n  }, \"non-local return\"), \". A \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"return\"), \" inside a JavaScript \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"forEach\"), \" callback would\\nonly return from that callback. Here it ends \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"find-long-name\"), \".\"), mdx(\"p\", null, \"See \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/blocks-and-lambdas\"\n  }, \"blocks and lambdas\"), \" for parameters and lifetime\\nrules.\"), mdx(\"h2\", {\n    \"id\": \"waiting-does-not-require-async-functions\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#waiting-does-not-require-async-functions\",\n    \"aria-label\": \"waiting does not require async functions permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Waiting does not require async functions\"), mdx(\"p\", null, \"In JavaScript, \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"async\"), \" functions return promises\"), \",\\nand \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"await\"), \" suspends their execution until a promise settles. In Toit, ordinary\\nfunctions can wait. The task keeps its call stack while another task runs;\\ncallers do not need an \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"async\"), \" marker or an \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"await\"), \" expression.\"), mdx(\"p\", null, \"Start a concurrent activity with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"task::\"), \". Within one program, tasks share\\nobjects and run cooperatively. They do not run in parallel. A busy loop without\\na yielding operation prevents other tasks from progressing.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"announce-later message/string -> none:\\n  sleep --ms=10\\n  print message\\n\\nmain:\\n  task:: announce-later \\\"Background done\\\"\\n  print \\\"Main continues\\\"\\n\")), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"announce-later\"), \" waits without any special function declaration. The main task\\ncan continue while the background task is asleep.\"), mdx(\"p\", null, \"The tradeoff is that yield points are not marked at each call site. A library\\ncall that waits can allow another task to modify shared objects. Check APIs and\\nuse \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/tasks#synchronizing-between-tasks-with-monitors\"\n  }, \"synchronization\"), \"\\nwhen an operation must remain consistent across waits. JavaScript's async/await\\nalso supports sequential-looking loops; the difference here is how waiting\\npropagates through ordinary calls.\"), mdx(\"h2\", {\n    \"id\": \"zero-and-empty-strings-are-truthy\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#zero-and-empty-strings-are-truthy\",\n    \"aria-label\": \"zero and empty strings are truthy permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Zero and empty strings are truthy\"), mdx(\"p\", null, \"JavaScript treats zero and the empty string as falsy; see\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://developer.mozilla.org/en-US/docs/Glossary/Truthy\"\n  }, \"MDN's truthiness rules\"), \".\\nToit treats only \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"false\"), \" and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \" as falsy. There is no separate \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"undefined\"), \"\\nvalue. \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"and\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"or\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"not\"), \" replace \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"&&\"), \", \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"||\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"!\"), \".\"), mdx(\"p\", null, \"This affects defaults: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value or fallback\"), \" preserves \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"0\"), \" and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"\\\"\\\"\"), \", but replaces\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"false\"), \". Check \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value == null\"), \" when a boolean \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"false\"), \" must also be preserved.\\nCheck \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".size == 0\"), \" when you mean an empty collection or string.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  print (0 or 10)\\n  print ((\\\"\\\" or \\\"fallback\\\").size)\\n  print (null or \\\"fallback\\\")\\n\")), mdx(\"p\", null, \"Expected output:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-text\"\n  }, \"0\\n0\\nfallback\\n\")), mdx(\"h2\", {\n    \"id\": \"numbers-distinguish-integers-from-floats\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#numbers-distinguish-integers-from-floats\",\n    \"aria-label\": \"numbers distinguish integers from floats permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Numbers distinguish integers from floats\"), mdx(\"p\", null, \"Toit has signed 64-bit \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"int\"), \" values and floating-point \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"float\"), \" values.\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"5 / 2\"), \" is \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"2\"), \", and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"5 / 2.0\"), \" is \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"2.5\"), \". When translating an average or a ratio\\nfrom JavaScript, ensure a floating-point operand is present if you need the\\nfraction. Convert text explicitly with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"int.parse\"), \" or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"float.parse\"), \" and use\\nstring interpolation to format a value as text.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  total := 5\\n  count := 2\\n  print (total / count)\\n  print (total.to-float / count)\\n  print (int.parse \\\"42\\\")\\n\")), mdx(\"p\", null, \"Expected output:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-text\"\n  }, \"2\\n2.5\\n42\\n\")), mdx(\"p\", null, \"See \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/math\"\n  }, \"numbers\"), \" and \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/typeconversion\"\n  }, \"conversions\"), \".\"), mdx(\"h2\", {\n    \"id\": \"choose-a-class-or-a-map\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#choose-a-class-or-a-map\",\n    \"aria-label\": \"choose a class or a map permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Choose a class or a map\"), mdx(\"p\", null, \"Toit objects have fields declared in their classes. You cannot build their\\nshape by assigning arbitrary new properties. Use a class for a known structure\\nand a map for dynamic keys. \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"{\\\"name\\\": \\\"Ada\\\"}\"), \" is a map; access it as\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"person[\\\"name\\\"]\"), \", not \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"person.name\"), \". \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"{:}\"), \" is an empty map; \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"{}\"), \" is an empty set.\"), mdx(\"p\", null, \"Create an instance by calling its class, without \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"new\"), \". A constructor parameter\\nsuch as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".name\"), \" initializes the corresponding field. Within methods, \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"this\"), \"\\nrefers to the receiver. Unlike JavaScript, fields and methods are already in\\nscope inside a method: write \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"name\"), \" or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"greet\"), \" without \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"this.\"), \".\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"class Person:\\n  name/string\\n\\n  constructor .name:\\n\\n  greet -> none:\\n    print \\\"Hello $name\\\"\\n\\nmain:\\n  person := Person \\\"Ada\\\"\\n  person.greet\\n  labels := {\\\"name\\\": person.name}\\n  print labels[\\\"name\\\"]\\n\")), mdx(\"p\", null, \"This prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Hello Ada\"), \", followed by \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Ada\"), \".\"), mdx(\"h2\", {\n    \"id\": \"types-are-checked-at-runtime\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#types-are-checked-at-runtime\",\n    \"aria-label\": \"types are checked at runtime permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Types are checked at runtime\"), mdx(\"p\", null, \"Toit lets you choose where to add type annotations. A parameter uses \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"/Type\"), \",\\nand a return type uses \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"-> Type\"), \". Here both arguments and the result must be\\nintegers:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"add a/int b/int -> int:\\n  return a + b\\n\\nmain:\\n  print (add 2 3)  // Prints 5.\\n  value/any := \\\"3\\\"\\n  error := catch: add 2 value\\n  if error:\\n    print \\\"Expected integers\\\"\\n\")), mdx(\"p\", null, \"The \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"any\"), \" annotation allows \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value\"), \" to hold any kind of value. Passing it to\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"add\"), \" checks whether it is an integer. Unlike TypeScript's erased annotations,\\nToit annotations check actual values when the program runs. The second call fails its check and prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Expected\\nintegers\"), \". The analyzer catches some mistakes before execution, but not every\\ntype error. Omitting an annotation allows dynamic values; \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"any\"), \" explicitly\\naccepts any value, including \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \".\"), mdx(\"h3\", {\n    \"id\": \"nullable-values\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#nullable-values\",\n    \"aria-label\": \"nullable values permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Nullable values\"), mdx(\"p\", null, \"Types exclude \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \" by default. Add \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"?\"), \" to allow it: \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"string?\"), \" means a string\\nor \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \". This is useful for a value that may be absent:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"greet name/string? -> none:\\n  print \\\"Hello $(name or \\\"World\\\")\\\"\\n\\nmain:\\n  greet \\\"Ada\\\"\\n  greet null\\n\")), mdx(\"p\", null, \"This prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Hello Ada\"), \", then \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Hello World\"), \". \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"none\"), \" marks a function with no\\nresult. A nullable value can be passed to a non-nullable parameter, but its\\nruntime value must satisfy that parameter's check; see\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/toitversus#nullable-types-and-assignments\"\n  }, \"nullable assignments\"), \".\"), mdx(\"h3\", {\n    \"id\": \"interfaces-are-explicit\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#interfaces-are-explicit\",\n    \"aria-label\": \"interfaces are explicit permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Interfaces are explicit\"), mdx(\"p\", null, \"TypeScript can accept an object because its shape matches an interface.\\nIn Toit, the class must declare \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"implements\"), \" as well as provide the methods:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"interface Named:\\n  name -> string\\n\\nclass Person implements Named:\\n  name/string\\n\\n  constructor .name:\\n\\nmain:\\n  person/Named := Person \\\"Ada\\\"\\n  print person.name\\n\")), mdx(\"p\", null, \"The public field supplies the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"name\"), \" getter required by the interface. Use\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value is Type\"), \" to test a type, or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"value as Type\"), \" for a checked cast. A cast\\ndoes not convert text to a number; use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"int.parse\"), \" for that.\\nSee \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/definitions#type\"\n  }, \"types\"), \" and\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/objects-constructors-inheritance-interfaces\"\n  }, \"classes\"), \".\"), mdx(\"h2\", {\n    \"id\": \"catching-errors-returns-a-value\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#catching-errors-returns-a-value\",\n    \"aria-label\": \"catching errors returns a value permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Catching errors returns a value\"), mdx(\"p\", null, mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"catch:\"), \" runs a block and returns the thrown value or \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"null\"), \" if nothing was\\nthrown. Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"try:\"), \" with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"finally:\"), \" for cleanup. This is different syntax from\\nJavaScript's \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"try\"), \"/\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"catch\"), \"/\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"finally\"), \" statement.\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-toit\"\n  }, \"main:\\n  error := catch:\\n    print (int.parse \\\"not a number\\\")\\n  if error:\\n    print \\\"Please enter an integer\\\"\\n\")), mdx(\"p\", null, \"This prints \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Please enter an integer\"), \".\"), mdx(\"p\", null, \"Exceptions are values; strings are common. For your own error protocols, throw\\na truthy value so the usual \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"if error\"), \" check detects it. Read\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/exceptions\"\n  }, \"exception handling\"), \" for cleanup and error propagation.\"), mdx(\"h2\", {\n    \"id\": \"modules-and-packages-are-resolved-before-running\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#modules-and-packages-are-resolved-before-running\",\n    \"aria-label\": \"modules and packages are resolved before running permalink\",\n    \"className\": \"table-of-contents-icon before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Modules and packages are resolved before running\"), mdx(\"p\", null, \"Each file is a library. \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"import .helpers\"), \" imports a neighboring \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"helpers.toit\"), \";\\nSDK imports use names such as \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"import math\"), \". Package dependencies are declared\\nin \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"package.yaml\"), \" and resolved versions live in \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"package.lock\"), \".\"), mdx(\"p\", null, \"JavaScript packages cannot be imported as Toit libraries. Continue with\\n\", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/imports\"\n  }, \"imports\"), \" and the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/language/package/pkgguide\"\n  }, \"package quick start\"), \"\\nto structure a project and add Toit dependencies.\"));\n}\n;\nMDXContent.isMDXComponent = true;","tableOfContents":{"items":[{"url":"#toit-for-javascripters","title":"Toit for JavaScripters","items":[{"url":"#calling-functions-and-methods","title":"Calling functions and methods"},{"url":"#variables-and-final-bindings","title":"Variables and final bindings"},{"url":"#named-arguments","title":"Named arguments"},{"url":"#strings-interpolate-with-","title":"Strings interpolate with $"},{"url":"#blocks-are-not-arrow-functions","title":"Blocks are not arrow functions"},{"url":"#waiting-does-not-require-async-functions","title":"Waiting does not require async functions"},{"url":"#zero-and-empty-strings-are-truthy","title":"Zero and empty strings are truthy"},{"url":"#numbers-distinguish-integers-from-floats","title":"Numbers distinguish integers from floats"},{"url":"#choose-a-class-or-a-map","title":"Choose a class or a map"},{"url":"#types-are-checked-at-runtime","title":"Types are checked at runtime","items":[{"url":"#nullable-values","title":"Nullable values"},{"url":"#interfaces-are-explicit","title":"Interfaces are explicit"}]},{"url":"#catching-errors-returns-a-value","title":"Catching errors returns a value"},{"url":"#modules-and-packages-are-resolved-before-running","title":"Modules and packages are resolved before running"}]}]}}},"pageContext":{"title":"For JavaScripters","id":"9d6ef69e-9e26-5ecd-941d-2eafba324096"}},
    "staticQueryHashes": ["2197327828"]}