title: How to share javascript in nativescript?
body: <p>I am building an app using nativescript and i've noticed i have a ton of repeated code.  The slideout drawer for example would have to be replicated on every page.  How do I share the backend javascript so I can just load in a file or whatever instead of having to rewrite the code on every page?</p>
  
  <p>For example I have a slideout drawer with view permissions and its called like this:</p>
  
  <pre><code>if (access[0]['page'] == 'Checks' &amp;&amp; access[0]['enabled'] == true) {pageData.set("Checks", true);}
  if (access[1]['page'] == 'Timeclock' &amp;&amp; access[1]['enabled'] == true) {pageData.set("Timeclock", true);}
  if (access[2]['page'] == 'Invoices' &amp;&amp; access[2]['enabled'] == true) {pageData.set("Invoices", true);}
  if (access[3]['page'] == 'EEInfo' &amp;&amp; access[3]['enabled'] == true) {pageData.set("EEInfo", true);}
  if (access[4]['page'] == 'CLInfo' &amp;&amp; access[4]['enabled'] == true) {pageData.set("CLInfo", true);}
  
  drawer = page.getViewById("drawer"); 
  </code></pre>
  
  <p>I don't want to have to repeat this on every page.</p>