ES6: The Next JavaScript II

This is the second post of my recurring series on ES6: The next JavaScript. I will be just doing some simple programming tasks in ES6 Javascript.

In my first post of this series, I covered some Introduction to ES6 and also wrote about how to setup your local machine to transpile ES6 with babel. In this post, I’ll explore ES6 classes and Arrow Functions.

Arrow Functions in ES6

So I promised that I’ll do all this while solving some very trivial programming tasks. So here is my task.

#Task 1: Write a Simle Currency Calculator that takes three Arguments, a Number for Conversion Rate, and two ISO 4217 Currency Strings and returns a function that converts any amount from one currency to another.

Solution: I did this thing via new Arrow functions in ES6, and actual Currency Converter code was just one line.[gist 2e2b436b11ac487ad7bf/]

Continue reading “ES6: The Next JavaScript II”

ES6: The Next JavaScript I – Setup

This is the first post of my recurring series on ES6: The next JavaScript. I will be just doing some simple programming tasks in ES6 Javascript.

What’s ES6?

Its the new Standard for Javascript. Its still in draft mode, as of writing this article. Its very important for new as well as experienced Javascript programmers to learn ES6 syntax and other concepts introduced by it, So that Javascript can be moved forward. (Yuck Legacy Code!)

Cool Features of ES6:-

  1. Its Backward Compatible: Even though its a really big change to Javascript syntax, But still your old Javascript code will continue to Work. (Huh!)
  2. New syntactic sugars: Javascript until now, didn’t have anything like classes and inheritance stuff, but we had prototypes. New ES6 classes syntax provides an excellent syntactic sugar for prototypal classes.
  3. Module System: ES6 introduces a new module system for Javascript with ‘import’ and ‘export’ keywords. (So you won’t have to use something like browserify to import one file from another, Cool!)
  4. Block Scoping: Javascript had only function scoping, but with ES6 it also gets block scoping, with the new ‘let’ keyword. It will help you to write more clean code without polluting the environment with use and throw variables that you only needed inside one for-loop etc.
  5. Promises: The thing that I am most excited about ES6 is the new Promises Support. Promises provide a mechanism to handle the results and errors from asynchronous operations. Until now, you need some external library like rsvp.js or q.js if you want to use promises.

There are many more cool features and I’ll try to get into each one of them during the course of this blog series.

The Setup

Continue reading “ES6: The Next JavaScript I – Setup”

My Favourite Tweets III

This time the list is very small, since I was doing something Important last two weeks.

Polymer 1.0 is released.

And Polymer is fast.

BTW, he’s homebrew’s author.

Happens a lot when you spell a lot of things wrong.

I agree that React is awesome.

When your server thinks you’re drunk but you’re not.

Always happens on the friday.

Reddit, this might be it.

Recently, Reddit banned some of subreddits(eg. /r/fatpeoplehate) that they considered as harmful/distasteful/demeaning to some kind of people. I don’t agree with what eveyone says on Reddit, but I think they should be able to say it.

Aaron Swartz, one of the cofounders of Reddit, was one of the proponents of Free Speech on the Internet. And for some time, Reddit did used to stand for Free Speech, time when Facebook was creating a Walled Garden of its own.

I used to love Reddit, It used to truly a place to say whatever you wanted to say. Currently, its new CEO and friends are trying to make it a more advertiser-friendly place. So they are eager to cut-off its ugly parts, the parts that made it a truly free speech place on Internet.

Join /r/PaoMustResign/ to fight against censorship on Reddit. We should either save Reddit or join

Quora Fails. (Tweet String)

I used to be a prominent reader on quora, Sometimes I even answered or asked questions. But All that seems like a distant past to me. I think Quora has failed to keep Noise Lower than Signal.

This is my tweet String on Quora.

  1. Rule No 1 on : Don’t Follow people. Follow Topics.
  2. Rule No 2 on : Whatever you do to clean your feed, its will always feel like 90% of spam.
  3. Rule No 3 on : You can’t get rid of Questions like “What does Thomas Cormen think about pirated copies of his books?”.