Writing classes in ES6

ES6 has introduced classes and object inheritance. These are welcome additions since they provide a more convenient way to build object-oriented code than before with functions and prototypes.

Unsurprisingly the keyword to build a class is “class”. Here’s the most simple class with a default empty constructor:

Read more of this post

Using the filter array helper in ES6

ES6 comes with a number of helper methods that can be applied to arrays. One of these is called filter which can filter out various elements from an array and add those elements to a new array. If you’re familiar with C# and LINQ then the filter function is very similar to the Where and ToList LINQ extension methods.

Let’s see an example:

Read more of this post

Default function arguments in ES6

JavaScript has been extended with default function arguments in ES6. They work much like in other languages such as C#.

Here’s an example with a two arguments, one compulsory, one default:

Read more of this post

For-of loops in ES6

ES6 has a new iterator that behaves like for-each loops in C# or Java. In ES6 it’s called a for-of loop. For-each / for-of loops come in very handy when looping through collections.

Here’s a short example:

Read more of this post

Using the map array helper in ES6

ES6 comes with a number of helper methods that can be applied to arrays. One of these is called map which can transform each element in an array and produce a new array from those transformed elements. If you’re familiar with C# and LINQ then the map function is very similar to the Select LINQ extension method.

Here’s an example to iterate through an array of integers and collect their squared values into a new array:

Read more of this post

Elliot Balynn's Blog

A directory of wonderful thoughts

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

WEB APPLICATION DEVELOPMENT TUTORIALS WITH OPEN-SOURCE PROJECTS

Once Upon a Camayoc

Bite-size insight on Cyber Security for the not too technical.

%d bloggers like this: