<script src="https://npmcdn.com/linq-es5/dist/linq.js"></script>
<h1>Using Library</h1>
<p>To use library in Browser <span class="pl-s">npmcdn.com/linq-es5/dist/linq.js</span> or <span class="pl-s">npmcdn.com/linq-es2015/dist/linq.js</span> must be added to the page.</p>
<p>Once loaded it creates <span class="pl-k">Enumerable</span> global variable which is used to access functionality.</p>
<p><span class="pl-k">Enumerable</span> exposes following functions: <span class="pl-sr">Range, Repeat, and asEnumerable</span></p>
<p>Lets generate array of 15 numbers strating from 0. <br/>Example: <span id="array" class="pl-sr"></span></p>
<p>Now, lets filter even numbers out <br/>Example: <span id="odd" class="pl-sr"></span></p>
<p>Now count odd numbers in the array: <span class="pl-sr" id="result">0</span></p>
<p>Or you could do it all at once: <span class="pl-sr" id="allatonce">0</span></p>
// To play with the library add code here
var array = Enumerable.Range(0, 15).ToArray(); // Generate test array from range
var range = Enumerable.asEnumerable( array ); // Convert array to enumerable
var filtered = range.Where(o => o % 2 == 1); // Filter out even numbers
// Update UI elements
document.getElementById('array').innerHTML = array;
document.getElementById('odd').innerHTML = filtered.ToArray();
document.getElementById('result').innerHTML = filtered.Count();
document.getElementById('allatonce').innerHTML =
Enumerable.Range(0, 150)
.Except(Enumerable.Range(50, 15))
.Where(o => o % 2 == 1)
.Count();
;
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.