hit tracker

Transpilers

Home » Transpilers

ECMAScript 2015/ES 6 features every C# developer would love to use

in C-Sharp, Programming, Uncategorized by Prayag Pavitran Comments are off

JavaScript is constantly evolving and has become one of the most popular languages used. Now a days JavaScript is not only used for building web Applications, it’s now being used for developing Desktop applications as well.

ECMA Script 2015/ES 6 is the current version of ECMA Script Language specification which defines the standard for JavaScript. ES 6 introduces some new features which were missing in ES 5(older JavaScript version) and is already been supported in some of the Transpilers like ‘TypeScript’.

Top Browsers have already started supporting most of the ES 6 features. Even if browser doesn’t support the feature, we can use any of the Transpiler like Babel which can compile code written in ES 6 to older version.

Transpilers or Transcompilers takes the source code of a program written in one programming language and converts the equivalent source code in another language.

Some of the most commonly used Transcompilers are Babel , TypeScript and CoffeeScript

I am listing below some of the ES 6 features which every developer coming from backend programming language like C# would love to use.

1) Constants: – Constants can be defined using “const” keyword. Values of the constants cannot be altered and if we try to change the values of the constants any point of time we’ll get a read-only error.

Try it                      

2) Block scope:- If a variable declared inside some block of code enclosed by curly braces is only visible within that block of code, and that variable is not visible outside of that particular block of code we call it a block scope. If we are familiar with some languages like C# we are already aware of block scope. In ES 6 let keyword is being introduced which helps us to define block scope variables in JavaScript.

Try it

3) Default Parameters: – Another feature which I liked most is Default Parameters. This feature can be compared to the Optional Parameter concept in C#. By using this feature we can set some default values for method parameters. If we pass the values to the parameters it will override the default parameters and if not it will take default value.

Try it

4) Classes: – Classes lower the barrier for people coming from other languages like C# and helps in building large complex systems .Some transpilers like “Transcript” already supports classes.

Try it

5) Inheritance: – This is another important feature that has been introduced in ES 6 and which is very useful for developers when working with large applications. Inheritance helps in reusing the code there by reducing a significant development time. This is also is supported in some of the Transpilers like ‘Transcript’.

Try it

6) String Interpolations: – With this feature we can avoid string manipulation using “+” operator and  have some clean code using back ticks ‘. Also we don’t have to use “\n” for line breaks any more.

Try it

Conclusion
Using ES6 many C# concepts carry over to JavaScript and by using it, you can push more functionality to the client side. With the new ES6 features like Classes and Inheritance we can use them in larger applications. Stay tuned for more features of ES6.