Showing posts from October, 2015

Javascript (ECMAScript 5.1) Refresher

I’ve been recently working heavily on JavaScript based applications in both Node.js and a Chrome extension. After working mostly on Java, I thought I’d share the syntax, conventions and the new features of ECMAScript 5.1 and parts of the still pending version, ES6 /ECMAScript 2015, that I’ve come across. Comparisons Operators == equal to === equal value and equal type != not equal !== not equal value or not equal type I saw something else I thought was a fancy notation: if (!!something) //which is not a special operator, it just converts it to boolean, i.e a double not. (!!something) === (!(!something)) //this would only be useful if you want to set a boolean to something truthy, i.e. var a = "somevalue"; var asBoolean = !!"somevalue"; Object Initializer Something I had thought was not a fully adopted syntax, was being able to specify the getter / setter functions in the initializer. (MDN Object initializer ) var o = { func1: function (p1, p2) {}, ge