title: Hiding data javascript functions from malicious user
body: <p>Let's say I'm listing clients into a html page that come from the server side, and these clients can be deleted by a button I include in the code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@foreach ($clients as $client) 
      &lt;td&gt;{!! client.name !!}&lt;/td&gt;&lt;td&gt;&lt;button type"button" onclick="delete({!! client.id!!})"&gt;
  @endforeach</code></pre>
  </div>
  </div>
  </p>
  
  <p>My question is is it safe to do that? Should I hide this function?</p>
  
  <p>And how to hide it? I thought I could write a jquery that refers to each of the clients listed, but for that I would have to create a javascript function for every single client.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@foreach ($clients as $client) 
      &lt;td&gt;{!! client.name !!}&lt;/td&gt;&lt;td&gt;&lt;button type"button" id="client{!! client.id !!}"&gt;
  @endforeach</code></pre>
  </div>
  </div>
  </p>
  
  <p>and then:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script type="text/javascript"&gt;
  @foreach ($clients as $client) 
      $('#client{!! $client.id !!}').click(function(){ doStuff({!! $client.id !!}); });
  @endforeach
  &lt;/script&gt;
  </code></pre>
  
  
  
  <p>Well, I think it is not a good solution because it still shows the client id in the button and I create many instances of the same code. My sense says there's must be another way, maybe a library for that. Does anyone have a little clue?</p>
  
  <p>Thank you.</p>
  
  <p>Obs.: I know I have to do validations in the server side, but this question is still important I think.</p>