 <p>The statement <code>$scope.messages = messageOptions.slice(0, messageOptions.length);</code> create a clone/copy of array and assigning it to <code>$scope.messages</code></p> <p>You can also achieve same using</p> <pre><code> $scope.messages = messageOptions.slice(); </code></pre> <p><em>Code to demonstrate</em> </p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var messageOptions = [1, 2]; var messages = messageOptions.slice(0, messageOptions.length); //Update messageOptions[0] = 100; snippet.log("messages: " + JSON.stringify(messages)); snippet.log("messageOptions: " + JSON.stringify(messageOptions));</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!-- Provides the `snippet` object, see http://meta.stackexchange.com/a/242144/134069 --&gt; &lt;script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p>