ES2015 (Aka ES6)

Privates In ES2015 Javascript Classes

One feature missing in ES2015 (formerly ES6) classes is the concept of a private variable or function. However, thanks to ES2015 modules we can actually easily define private properties and functions that can only be accessed within our class. Private Properties in ES2015 classes Using a WeakMap which we have discussed before, we are going to implement the concept of private class properties. Because classes are just objects, we can use WeakMaps on them. Then by specifying getter and or setter methods on the class, we can control access to these private properties. The beautiful thing about this is that using the export keyword, we are only exposing the class Person. This is akin to the revealing module pattern where we choose what is exposed to the client.

TypeScript vs ECMAScript 2015/2016

As Javascript slowly becomes a less salty language thanks in part to ECMAScript 2015 (formerly ES6) amd ECMAScript 2016 (formerly ES7), the question of whether to choose a superset of the Javascript language or write POJ (Plain Old Javascript) is a question we need to ask ourselves. My experience with TypeScript is rather minimal, whilst investigating Javascript frameworks a few months ago I used TypeScript for a little while to get a feel for it and see what it would offer me in terms of workflow and efficiency. The fact the project would be built in .NET which means using Visual Studio 2013 was also a point towards TypeScript (of which Visual Studio fully supports).

Abstract Classes In Javascript

Modern Javascript is a lot different to Javascript of 2010. We have considerably more methods and means of doing things that we did not have previously. Some of those include classes, generators, arrow functions and a few other high-profile additions. One aspect of Javascript that not even ES2015 nor ES2016 covers is the concept of abstract classes. The ability to specify a class that defines how child classes should look, more specifically ensuring they specify certain methods.

A Guide To ES6 Classes

You might have noticed I have been writing about ES6 a lot lately. This is because I am excited about ES6 and thanks to the use of transpilers we can actually use it right now until browsers catch up. What are Javascript classes? In many ways, they are a sham. Javascript classes don’t really exist other than for cosmetic reasons. They are syntactic sugar over existing Javascript prototypical inheritance. The reason for this was to ensure backwards compatibility, classes merely give you a cleaner way to organise your code.

Default Parameter Values On Javascript Functions

It’s time for another ES6 post. This time, we’re talking about arguably one of the best additions to Javascript that is up there with modules and classes. I am talking about the ability to specify default parameter values on a Javascript function. This is one of the biggest missing pieces in Javascript in my opinion. I have encountered the need for this numerous times and while you can definitely implement a solution that does the job, there has been no support for native parameter values until ES6.

What Are Weakmaps In ES6?

With ES6 comes a plethora of new features and changes, one of those is Weakmaps – essentially Weakmaps are a collection of keys and values with the main constraint being the key has to be an object. In-fact, Weakmaps are very similar to that of standard ES6 maps, with a few constraints. Unlike using a map which allows for arbitrarily named keys, the key in a Weakmap is an object which can either be {} or function() {} because functions inherit from object.

A Guide To ES6 Arrow Functions =>

One of many favourite things in ECMAScript 6 (aka ES6) is the newly added arrow functions. If you’re a Coffeescript user then the arrow function premise is not entirely new to you. Essentially it allows you to create an anonymous function with the contextual value of “this” being the scope of the function being that of the outer function that the arrow function is being defined in. Nor does it expect you to use the keyword function