pxt-calliope/docs/js/functions.html

313 lines
74 KiB
HTML
Raw Normal View History

2017-08-19 17:16:35 +02:00
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta charset="UTF-8">
<title>calliope mini - Blocks / Javascript editor - calliope</title>
<meta name="Description" content="A Blocks / JavaScript code editor for the calliope mini." />
<!-- include meta.html -->
<!-- This file is typically overriden by the target, with own Twitter
account etc. Most data is taken from the theme file though.
-->
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@mspxtio" />
<meta name="twitter:title" content="calliope mini - Blocks / Javascript editor - calliope" />
<meta name="twitter:description" content="A Blocks / JavaScript code editor for the calliope mini." />
<meta name="twitter:image" content="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAIAAACyr5FlAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4AoUFBUNHXD4TgAAG/NJREFUeNrtnXmQHNd933+vp7tnpueenZm9L2CxC3BDHCQIgDYjQbwAXqYsyopcpK0KJVmpVJJyVSqVlFNJlROXS2W5YiuxXFE5ksySypJFy6YpWpZ4SDxFAiQgAAQBEscusJg9Z+fonruP98sfs1gugJ3dnpm+dnc+tUUsge6Z1+99+/d77/d+7z2CiNCmzWowdhegjXNpi6NNXdriaFOXtjja1KUtjjZ1aYujTV3a4mhTl7Y42tSlLY42dWmLo01d2uJoU5e2ONrUhbW7AE5leT6SELuLYhttcQDVtHJBlDJzYmpWyswXcovVUkGRK4BIXC7e7fX4gsFoZyjeHero9kfibo+wRRSzdcWhytX07NVrF04lL5xKJS/nsym5UqSatvrVhLAs5/GHwvGe7uHbBnbu6x4eD0TihNnMfplswXyOQjZ1+czbH534xezlD4r5LDReAy6WCyd6h8cPjN11X8/2cY732P1MprC1xCG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jyKM6jEbAABAGJYKNc+CGh8gnsC6ExMUccA044GIUlaqlKyOjG1UcVwplf7PfOrUtr03BbjqwTHkSMQfXt9sAMD1STiGBwTq7QCXrplSQsjDffFBnynGg
<meta property="og:title" content="calliope mini - Blocks / Javascript editor - calliope" />
<meta property="og:site_name" content="PXT" />
<meta property="og:type" content="website" />
<meta property="og:description" content="A Blocks / JavaScript code editor for the calliope mini." />
<meta property="fb:app_id" content="" />
<meta property="og:image" content="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAIAAACyr5FlAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4AoUFBUNHXD4TgAAG/NJREFUeNrtnXmQHNd933+vp7tnpueenZm9L2CxC3BDHCQIgDYjQbwAXqYsyopcpK0KJVmpVJJyVSqVlFNJlROXS2W5YiuxXFE5ksySypJFy6YpWpZ4SDxFAiQgAAQBEscusJg9Z+fonruP98sfs1gugJ3dnpm+dnc+tUUsge6Z1+99+/d77/d+7z2CiNCmzWowdhegjXNpi6NNXdriaFOXtjja1KUtjjZ1aYujTV3a4mhTl7Y42tSlLY42dWmLo01d2uJoU5e2ONrUhbW7AE5leT6SELuLYhttcQDVtHJBlDJzYmpWyswXcovVUkGRK4BIXC7e7fX4gsFoZyjeHero9kfibo+wRRSzdcWhytX07NVrF04lL5xKJS/nsym5UqSatvrVhLAs5/GHwvGe7uHbBnbu6x4eD0TihNnMfplswXyOQjZ1+czbH534xezlD4r5LDReAy6WCyd6h8cPjN11X8/2cY732P1MprC1xCGl5z9895X33/ynVPJSXSPRCG7BP7jzzj2HHx8aP9C0RFRNu5ac+ejCxMzsvKyoxj4yQ4jPJ2wb6h/bsS0aDTd071YRh1wpnT/28rs/+35q+jJSauyH8x5hZO89Bx96qmt4JyGNOZqZuYXnfvzi28dOZHOSeW3BsuxAf88jRz51+BOH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+SK6mxqtkAAEAAT1jjfLd6FiQM9d18iixF7BM8j/YbbDw0TRPTOdXoYyKbYDOKY8mV7Dn70JcWRvcDYW7qi/EMeTDiD91oNmp3Es6teaO3akNjPeCN3OpxasZjyO810HgAgFyVxUyO2h2E3WziWHIl+4+ef+ALhfgNrqQGRRgT+AO3mo3a7YShvhjetH09guYJE1641aKYZDwAoFwoFXI27yGwqcRBkOaj3efufWry0COq10dWO3WFq2s2AAAAAbwRjfOu1AESQoUYYVYfYRJCHupNGG48AKAg5ksFO/dK3yziQERC5rftff/olxdG77zVldSgCDu9/MGAUL8dkXCC5rnBg1AXj0LdmReK2O/zPNKXMDzrh1IqZXJy1bbjYzaDOAhS1S1M7j96/v7fLcb7SP2WX8ds1D6NYTRfDJdbGlFzh4jbt0YQiRDycJ8pxkNVVDGdMyZRvnE2vDgI0ny054P7npo8WNeV1KAIY17+YFBYpwURwNuhuZYSf5CAJnSQNefkzDMeAFAtV6SMaEtkbAOLgwAsuZKHvpTaUdeVLKPHbAAAABJe0DyhpXAZw6EQW3dyzTzjAQClfLEoFUyuzlXYwOIoIrm4577z9/9OMdZH1jvxjyKM6jEbAABAGJYKNc+CGh8gnsC6ExMUccA044GIUlaqlKyOjG1UcVwplf7PfOrUtr03BbjqwTHkSMQfXt9sAMD1STiGBwTq7QCXrplSQsjDffFBnynGg2
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAIAAACyr5FlAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4AoUFBUNHXD4TgAAG/NJREFUeNrtnXmQHNd933+vp7tnpueenZm9L2CxC3BDHCQIgDYjQbwAXqYsyopcpK0KJVmpVJJyVSqVlFNJlROXS2W5YiuxXFE5ksySypJFy6YpWpZ4SDxFAiQgAAQBEscusJg9Z+fonruP98sfs1gugJ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ERC5rftff/olxdG77zVldSgCDu9/MGAUL8dkXCC5rnBg1AXj0LdmReK2O/zPNKXMDzrh1IqZXJy1bbjYzaDOAhS1S1M7j96/v7fLcb7SP2WX8ds1D6NYTRfDJdbGlFzh4jbt0YQiRDycJ8pxkNVVDGdMyZRvnE2vDgI0ny054P7npo8WNeV1KAIY17+YFBYpwURwNuhuZYSf5CAJnSQNefkzDMeAFAtV6SMaEtkbAOLgwAsuZKHvpTaUdeVLKPHbAAAABJe0DyhpXAZw6EQW3dyzTzjAQClfLEoFUyuzlXYwOIoIrm4577z9/9OMdZH1jvxjyKM6jEbAABAGJYKNc+CGh8gnsC6ExMUccA044GIUlaqlKyOjG1UcVwplf7PfOrUtr03BbjqwTHkSMQfXt9sAMD1STiGBwTq7QCXrplSQsjDffFBn
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAIAAACyr5FlAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4AoUFBUNHXD4TgAAG/NJREFUeNrtnXmQHNd933+vp7tnpueenZm9L2CxC3BDHCQIgDYjQbwAXqYsyopcpK0KJVmpVJJyVSqVlFNJlROXS2W5YiuxXFE5ksySypJFy6YpWpZ4SDxFAiQgAAQBEscusJg9Z+fonruP98sfs1gugJ3dnpm+dnc+tUUsge6Z1+99+/d77/d+7z2CiNCmzWowdhegjXNpi6NNXdriaFOXtjja1KUtjjZ1aYujTV3a4mhTl7Y42tSlLY42dWmLo01d2uJoU5e2ONrUhbW7AE5leT6SELuLYhttcQDVtHJBlDJzYmpWyswXcovVUkGRK4BIXC7e7fX4gsFoZyjeHero9kfibo+wRRSzdcWhytX07NVrF04lL5xKJS/nsym5UqSatvrVhLAs5/GHwvGe7uHbBnbu6x4eD0TihNnMfplswXyOQjZ1+czbH534xezlD4r5LDReAy6WCyd6h8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OIoIrm4577z9/9OMdZH1jvxjyKM6jEbAABAGJYKNc+CGh8gnsC6ExMUccA044GIUlaqlKyOjG1UcVwplf7PfOrUtr03BbjqwTHkSMQfXt9sAMD1STiGBwTq7QCXrplSQsjDffFBnynGg2qam
<meta name="theme-color" content="#249899">
<!-- end include meta.html -->
<!-- include head.html -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
<link rel="stylesheet" href="/pxt-calliope/semantic.css" />
<link rel="stylesheet" href="/pxt-calliope/docfiles/style.css" />
<link rel="stylesheet" href="/pxt-calliope/docfiles/vs.css" />
<link rel="stylesheet" href="/pxt-calliope/docfiles/target.css" />
<link rel="stylesheet" href="/pxt-calliope/docfiles/fork.css" />
<script src="/pxt-calliope/jquery.js"></script>
<script src="/pxt-calliope/semantic.js"></script>
<script src="/pxt-calliope/lzma/lzma_worker-min.js"></script>
<script src="/pxt-calliope/embed.js" type="text/javascript"></script>
<script src="/pxt-calliope/docfiles/docs.js" type="text/javascript"></script>
<script src="/pxt-calliope/docfiles/target.js" type="text/javascript"></script>
<script src="/pxt-calliope/docfiles/fork.js" type="text/javascript"></script>
<style>
.ui.accent { color: #249899; }
.ui.inverted.accent { background: #249899; }
</style>
<script>
$(document).ready(function() {
// patch youtube in semantic
if ($ && $.fn && $.fn.embed && $.fn.embed.settings && $.fn.embed.settings.sources && $.fn.embed.settings.sources.youtube) {
$.fn.embed.settings.sources.youtube.url = '//www.youtube.com/embed/{id}?rel=0'
}
$('.ui.embed').embed();
})
</script>
<!-- end include head.html -->
</head>
<body id='root' class='root'>
<!-- include header.html -->
<div class="ui fixed accent inverted menu">
<div class="ui container">
<a href="/pxt-calliope/docs/.html" class="header item">
<img class="ui mini image" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5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iAgICAgaWQ9Imc0OTU1IgogICAgIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yNjAuOTAwMjUsLTIwNC4xKSI+PGcKICAgICAgIGlkPSJnNDk1NyI+PGRlZnMKICAgICAgICAgaWQ9ImRlZnM0OTU5Ij48cmVjdAogICAgICAgICAgIGlkPSJTVkdJRF83XyIKICAgICAgICAgICB4PSIxOTMuMTAwMDEiCiAgICAgICAgICAgeT0iMjA0LjEwMDAxIgogICAgICAgICAgIHdpZHRoPSIzMTguMjk5OTkiCiAgICAgICAgICAgaGVpZ2h0PSIyNTYuMjk5OTkiIC8+PC9kZWZzPjxjbGlwUGF0aAogICAgICAgICBpZD0iU1ZHSURfMV8iPjx1c2UKICAgICAgICAgICB4bGluazpocmVmPSIjU1ZHSURfN18iCiAgICAgICAgICAgb3ZlcmZsb3c9InZpc2libGUiCiAgICAgICAgICAgaWQ9InVzZTQ5NjMiCiAgICAgICAgICAgc3R5bGU9Im92ZXJmbG93OnZpc2libGUiCiAgICAgICAgICAgeD0iMCIKICAgICAgICAgICB5PSIwIgogICAgICAgICAgIHdpZHRoPSIxMDAlIgogICAgICAgICAgIGhlaWdodD0iMTAwJSIgLz48L2NsaXBQYXRoPjwvZz48ZwogICAgICAgaWQ9Imc0OTY1Ij48ZGVmcwogICAgICAgICBpZD0iZGVmczQ5NjciPjxyZWN0CiAgICAgICAgICAgaWQ9IlNWR0lEXzlfIgogICAgICAgICAgIHg9IjE5My4xMDAwMSIKICAgICAgICAgICB5PSIyMDQuMTAwMDEiCiAgICAgICAgICAgd2lkdGg9IjMxOC4yOTk5OSIKICAgICAgICAgICBoZWlnaHQ9IjI1Ni4yOTk5OSIgLz48L2RlZnM+PGNsaXBQYXRoCiAgICAgICAgIGlkPSJTVkdJRF8yXyI+PHVzZQogICAgICAgICAgIHhsaW5rOmhyZWY9IiNTVkdJRF85XyIKICAgICAgICAgICBvdmVyZmxvdz0idmlzaWJsZSIKICAgICAgICAgICBpZD0idXNlNDk3MSIKICAgICAgICAgICBzdHlsZT0ib3ZlcmZsb3c6dmlzaWJsZSIKICAgICAgICAgICB4PSIwIgogICAgICAgICAgIHk9IjAiCiAgICAgICAgICAgd2lkdGg9IjEwMCUiCiAgICAgICAgICAgaGVpZ2h0PSIxMDAlIiAvPjwvY2xpcFBhdGg+PC9nPjxnCiAgICAgICBpZD0iZzQ5NzMiPjxkZWZzCiAgICAgICAgIGlkPSJkZWZzNDk3NSI+PHJlY3QKICAgICAgICAgICBpZD0iU1ZHSURfMTFfIgogICAgICAgICAgIHg9IjE5My4xMDAwMSIKICAgICAgICAgICB5PSIyMDQuMTAwMDEiCiAgICAgICAgICAgd2lkdGg9IjMxOC4yOTk5OSIKICAgICAgICAgICBoZWlnaHQ9IjI1Ni4yOTk5OSIgLz48L2RlZnM+PGNsaXBQYXRoCiAgICAgICAgIGlkPSJTVkdJRF8zXyI+PHVzZQogICAgICAgICAgIHhsaW5rOmhyZWY9IiNTVkdJRF8xMV8iCiAgICAgICAgICAgb3ZlcmZsb3c9InZpc2libGUiCiAgICAgICAgICAgaWQ9InVzZTQ5NzkiCiAgICAgICAgICAgc3R5bGU9Im92ZXJmbG93OnZpc
</a>
<!-- Menu -->
</div>
</div>
<!-- end include header.html -->
<div id="docs" class="ui main container mainbody">
<div class="ui breadcrumb">
<a class=" section"
href="/pxt-calliope/docs/js.html">js</a><i class="right chevron icon divider"></i><a class="active section"
href="/pxt-calliope/docs/js/functions.md.html">functions.md</a>
</div>
<div class="ui text">
<h1 id="functions">Functions</h1>
<p>Functions are the fundamental building block of programs. Here is the simplest
way to make a function that adds two numbers:</p>
<pre><code class="lang-ts"><span class="hljs-comment">// Named function</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">x : <span class="hljs-built_in">number</span>, y : <span class="hljs-built_in">number</span></span>) </span>{
<span class="hljs-keyword">return</span> x + y;
}
basic.showNumber(add(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>))</code></pre>
<div class="ui info message">
<div class="content">
<p>For the Calliope mini, you must specify a <a href="/pxt-calliope/docs/js/types.html">type</a> for each function parameter. </p>
</div>
</div>
<p>Functions can refer to variables outside of the function body.
When they do so, theyre said to <code>capture</code> these variables.</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> z = <span class="hljs-number">100</span>;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addToZ</span>(<span class="hljs-params">x: <span class="hljs-built_in">number</span>, y: <span class="hljs-built_in">number</span></span>) </span>{
<span class="hljs-keyword">return</span> x + y + z;
}
basic.showNumber(addToZ(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>))</code></pre>
<h2 id="typing-the-function">Typing the function</h2>
<p>Lets add a return type to our add function:</p>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">x: <span class="hljs-built_in">number</span>, y: <span class="hljs-built_in">number</span></span>): <span class="hljs-title">number</span> </span>{
<span class="hljs-keyword">return</span> x + y;
}</code></pre>
<p>TypeScript can figure the return type out by looking at the return statements, so you can optionally leave this off in many cases.</p>
<h1 id="optional-and-default-parameters">Optional and Default Parameters</h1>
<p>In TypeScript, the number of arguments given to a function has to match the number of parameters the function expects.</p>
<pre><code class="lang-ts-ignore"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">buildName</span>(<span class="hljs-params">firstName: <span class="hljs-built_in">string</span>, lastName: <span class="hljs-built_in">string</span></span>) </span>{
<span class="hljs-keyword">return</span> firstName + <span class="hljs-string">" "</span> + lastName;
}
<span class="hljs-keyword">let</span> result1 = buildName(<span class="hljs-string">"Bob"</span>); <span class="hljs-comment">// error, too few parameters</span>
<span class="hljs-keyword">let</span> result2 = buildName(<span class="hljs-string">"Bob"</span>, <span class="hljs-string">"Adams"</span>, <span class="hljs-string">"Sr."</span>); <span class="hljs-comment">// error, too many parameters</span>
<span class="hljs-keyword">let</span> result3 = buildName(<span class="hljs-string">"Bob"</span>, <span class="hljs-string">"Adams"</span>); <span class="hljs-comment">// ah, just right</span></code></pre>
<p>In JavaScript, every parameter is optional, and users may leave them off as they see fit.
When they do, their value is <code>undefined</code>.
We can get this functionality in TypeScript by adding a <code>?</code> to the end of parameters we want to be optional.
For example, lets say we want the last name parameter from above to be optional:</p>
<pre><code class="lang-ts-ignore"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">buildName</span>(<span class="hljs-params">firstName: <span class="hljs-built_in">string</span>, lastName?: <span class="hljs-built_in">string</span></span>) </span>{
<span class="hljs-keyword">if</span> (lastName)
<span class="hljs-keyword">return</span> firstName + <span class="hljs-string">" "</span> + lastName;
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">return</span> firstName;
}
<span class="hljs-keyword">let</span> result1 = buildName(<span class="hljs-string">"Bob"</span>); <span class="hljs-comment">// works correctly now</span>
<span class="hljs-keyword">let</span> result2 = buildName(<span class="hljs-string">"Bob"</span>, <span class="hljs-string">"Adams"</span>, <span class="hljs-string">"Sr."</span>); <span class="hljs-comment">// error, too many parameters</span>
<span class="hljs-keyword">let</span> result3 = buildName(<span class="hljs-string">"Bob"</span>, <span class="hljs-string">"Adams"</span>); <span class="hljs-comment">// ah, just right</span></code></pre>
<p>Any optional parameters must follow required parameters.
Had we wanted to make the first name optional rather than the last name, we would need to change the order of parameters in the function, putting the first name last in the list.</p>
<p>In TypeScript, we can also set a value that a parameter will be assigned if the user does not provide one, or if the user passes <code>undefined</code> in its place.
These are called default-initialized parameters.
Lets take the previous example and default the last name to <code>&quot;Smith&quot;</code>.</p>
<pre><code class="lang-ts-ignore">function buildName(firstName: string, lastName = &quot;Smith&quot;) {
return firstName + &quot; &quot; + lastName;
}
let result1 = buildName(&quot;Bob&quot;); // works correctly now, returns &quot;Bob Smith&quot;
let result2 = buildName(&quot;Bob&quot;, undefined); // still works, also returns &quot;Bob Smith&quot;
let result3 = buildName(&quot;Bob&quot;, &quot;Adams&quot;, &quot;Sr.&quot;); // error, too many parameters
let result4 = buildName(&quot;Bob&quot;, &quot;Adams&quot;); // ah, just right</code></pre>
<p>Default-initialized parameters that come after all required parameters are treated as optional, and just like optional parameters, can be omitted when calling their respective function.
This means optional parameters and trailing default parameters will share commonality in their types, so both</p>
<pre><code class="lang-ts"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">buildName</span>(<span class="hljs-params">firstName: <span class="hljs-built_in">string</span>, lastName?: <span class="hljs-built_in">string</span></span>) </span>{
<span class="hljs-comment">// ...</span>
}</code></pre>
<p>and</p>
<pre><code class="lang-ts">function buildName(firstName: string, lastName = &quot;Smith&quot;) {
// ...
}</code></pre>
<p>share the same type <code>(firstName: string, lastName?: string) =&gt; string</code>.
The default value of <code>lastName</code> disappears in the type, only leaving behind the fact that the parameter is optional.</p>
<p>Unlike plain optional parameters, default-initialized parameters dont <em>need</em> to occur after required parameters.
If a default-initialized parameter comes before a required parameter, users need to explicitly pass <code>undefined</code> to get the default initialized value.
For example, we could write our last example with only a default initializer on <code>firstName</code>:</p>
<pre><code class="lang-ts-ignore">function buildName(firstName = &quot;Will&quot;, lastName: string) {
return firstName + &quot; &quot; + lastName;
}
let result1 = buildName(&quot;Bob&quot;); // error, too few parameters
let result2 = buildName(&quot;Bob&quot;, &quot;Adams&quot;, &quot;Sr.&quot;); // error, too many parameters
let result3 = buildName(&quot;Bob&quot;, &quot;Adams&quot;); // okay and returns &quot;Bob Adams&quot;
let result4 = buildName(undefined, &quot;Adams&quot;); // okay and returns &quot;Will Adams&quot;</code></pre>
<h1 id="rest-parameters">Rest Parameters</h1>
<p>Required, optional, and default parameters all have one thing in common: they talk about one parameter at a time.
Sometimes, you want to work with multiple parameters as a group, or you may not know how many parameters a function will ultimately take.
In JavaScript, you can work with the arguments directly using the <code>arguments</code> variable that is visible inside every function body.</p>
<p>In TypeScript, you can gather these arguments together into a variable:</p>
<pre><code class="lang-ts-ignore"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">buildName</span>(<span class="hljs-params">firstName: <span class="hljs-built_in">string</span>, ...restOfName: <span class="hljs-built_in">string</span>[]</span>) </span>{
<span class="hljs-keyword">return</span> firstName + <span class="hljs-string">" "</span> + restOfName.join(<span class="hljs-string">" "</span>);
}
<span class="hljs-keyword">let</span> employeeName = buildName(<span class="hljs-string">"Joseph"</span>, <span class="hljs-string">"Samuel"</span>, <span class="hljs-string">"Lucas"</span>, <span class="hljs-string">"MacKinzie"</span>);</code></pre>
<p><em>Rest parameters</em> are treated as a boundless number of optional parameters.
When passing arguments for a rest parameter, you can use as many as you want; you can even pass none.
The compiler will build an array of the arguments passed in with the name given after the ellipsis (<code>...</code>), allowing you to use it in your function.</p>
<p>The ellipsis is also used in the type of the function with rest parameters:</p>
<pre><code class="lang-ts-ignore"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">buildName</span>(<span class="hljs-params">firstName: <span class="hljs-built_in">string</span>, ...restOfName: <span class="hljs-built_in">string</span>[]</span>) </span>{
<span class="hljs-keyword">return</span> firstName + <span class="hljs-string">" "</span> + restOfName.join(<span class="hljs-string">" "</span>);
}
<span class="hljs-keyword">let</span> buildNameFun: <span class="hljs-function">(<span class="hljs-params">fname: <span class="hljs-built_in">string</span>, ...rest: <span class="hljs-built_in">string</span>[]</span>) =&gt;</span> <span class="hljs-built_in">string</span> = buildName;</code></pre>
<a class="ui primary button" href="/pxt-calliope/docs/js/types.html">
<p>NEXT: Types</p>
</a>
</div>
<p style="margin-top:1em"><a href="https://github.com/Microsoft/pxt-calliope/blob/master/docs/docs/js/functions.md"><i class="write icon"></i>Edit this page on GitHub</a></p>
</div>
<!-- include footer.html -->
<div class="ui inverted accent vertical footer segment">
<div class="ui center aligned container">
<div class="ui horizontal inverted small divided link list">
<a class="item" href="https://www.pxt.io/" title="Programming Experience Toolkit">Powered by PXT</a>
<a class="item" href="https://www.pxt.io/contact">Contact Us</a>
<a class="item" href="https://www.pxt.io/privacy">Privacy &amp; Cookies</a>
<a class="item" href="https://www.pxt.io/legal">Terms Of Use</a>
<a class="item" href="https://www.pxt.io/trademarks">Trademarks</a>
<div class="item">© 2016 Microsoft</div>
<!-- we need to force the browser to load this font -->
<div style='font-family: Icons; color: #010101;' aria-hidden="true">.</div>
</div>
<a class="item" href="https://www.microsoft.com/"><img class="ui centered image" src="https://az851932.vo.msecnd.net/pub/pmapoirq" /></a>
</div>
</div>
<!-- end include footer.html -->
<!-- include macros.html -->
<!-- macro button -->
<!-- macro vimeo -->
<!-- macro youtube -->
<!-- macro section -->
<!-- macro hide -->
<!-- macro avatar -->
<!-- macro hint -->
<!-- wrapped around ordinary content -->
<!-- macro main-container -->
<!-- used for 'column' box - they are collected and wrapped in 'column-container' -->
<!-- macro column -->
<!-- macro column-container -->
<!-- Menu on the top of the page -->
<!-- macro item -->
<!-- macro divider -->
<!-- macro top-dropdown -->
<!-- macro inner-dropdown -->
<!-- end include macros.html -->
<!-- include tracking.html -->
<script type="text/javascript">
var appInsights=window.appInsights||function(config){
function i(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s="AuthenticatedUserContext",h="start",c="stop",l="Track",a=l+"Event",v=l+"Page",y=u.createElement(o),r,f;y.src=config.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js";u.getElementsByTagName(o)[0].parentNode.appendChild(y);try{t.cookie=u.cookie}catch(p){}for(t.queue=[],t.version="1.0",r=["Event","Exception","Metric","PageView","Trace","Dependency"];r.length;)i("track"+r.pop());return i("set"+s),i("clear"+s),i(h+a),i(c+a),i(h+v),i(c+v),i("flush"),config.disableExceptionTracking||(r="onerror",i("_"+r),f=e[r],e[r]=function(config,i,u,e,o){var s=f&&f(config,i,u,e,o);return s!==!0&&t["_"+r](config,i,u,e,o),s}),t
}({
instrumentationKey:"9801ed01-c40f-46ec-aa40-2a1742a9e71c",
disableAjaxTracking: true,
overridePageViewDuration: false,
disableExceptionTracking: true,
isCookieUseDisabled: true,
isStorageUseDisabled: true
});
window.appInsights=appInsights;
appInsights.queue.push(function () {
appInsights.context.addTelemetryInitializer(function (envelope) {
if (typeof pxtConfig === "undefined") return;
var telemetryItem = envelope.data.baseData;
telemetryItem.properties = telemetryItem.properties || {};
telemetryItem.properties["target"] = pxtConfig.targetId;
telemetryItem.properties["version"] = pxtConfig.targetVersion;
telemetryItem.properties["stage"] = (pxtConfig.relprefix || "/--").replace(/[^a-z]/ig, '')
if (typeof window !== "undefined" && window.location && /[?&]electron=1/i.test(window.location.href))
telemetryItem.properties["electron"] = 1;
});
});
appInsights.trackPageView();
</script>
<!-- end include tracking.html -->
</body>
</html>