explicit and implicit c#

The implicit and explicit keywords in C# are used when declaring conversion operators. Let’s say that you have the following class: public class Role { public string Name { get; set; } } If you want to create a new Role and assign a Name to it, you will typically do it like this: Role … Read more

Benefits of pure function

pure lets the compiler know that it can make certain optimisations about the function: imagine a bit of code like for (int i = 0; i < 1000; i++) { printf(“%d”, fun(10)); } With a pure function, the compiler can know that it needs to evaluate fun(10) once and once only, rather than 1000 times. … Read more

Webstorm not recognising JavaScript file

So I see three possible reasons for the problem: The file was marked as ‘Plain text’ There is a pattern for ‘Text files’ file type that matches this file (or back: file type ‘JavaScript’ exclude this file name). See image below There is a custom plugin that overrides default behavior for files with this name … Read more

Easiest way to sort DOM nodes?

Though there’s probably an easier way to do this using a JS Library, here’s a working solution using vanilla js. var list = document.getElementById(‘mylist’); var items = list.childNodes; var itemsArr = []; for (var i in items) { if (items[i].nodeType == 1) { // get rid of the whitespace text nodes itemsArr.push(items[i]); } } itemsArr.sort(function(a, … Read more