visage|SDK for HTML5 — face tracking in JavaScriptcountUp.js — dependency-free, lightweight JavaScript "class" to create animations with numerical dataSemicolon.js — the most useful JavaScript library for cargo cult programmersInternational Telephone Input — adds a flag dropdown to any input, which lists all the countries and their international dial codes next to their flags

So what do you make of these recent going ons?

Is node-webkit the next big thing? Are you still confused by closures? Do you have your own list of resources to share?

Either way, we'd be glad to hear your opinion.

Please PM us if you have anything of interest for the next issue, and happy reading! - [Paul & [URL="http://www.sitepoint.com/forums/private.php?do=newpm&u=184222"]Pullo](http://www.sitepoint.com/forums/private.php?do=newpm&u=158377)

system
—
2014-01-13T11:40:20Z —
#2

I keep stumbling across React by I can't seem to find the time for it, just like the author of the What is React? article.

The fact that it completely mocks the DOM and only touching the real thing when it needs to, that's one thing that I find reason enough to get into it.

Very good write-up and completely agree with the author about Functional Programming in JavaScript.

Pullo
—
2014-01-14T09:42:52Z —
#4

myty said:

I keep stumbling across React by I can't seem to find the time for it, just like the author of the What is React? article.

I know the feeling I've heard about it, but hadn't had time to look at it in any detail either.However after reading this, it has made its way to the upper part of my "To look at when I've got time" list, along with [Ember, [URL="http://www.poodr.com/"]POODR and running [URL="http://lifehacker.com/5938332/how-to-run-mac-os-x-on-any-windows-pc-using-virtualbox"]MacOS in VirtualBox](http://emberjs.com/).

myty said:

Also, nice article about Google Dart, very interesting read.

Do you have any thoughts about whether this would be a good or a bad thing?At first glance it seems an exciting development, but on the other hand it runs the danger of fragmenting the ecosystem and as Mr Eich says, two VMs, with their own GC and both attempting to interact with the DOM sounds a bit like a recipe for disaster.

system
—
2014-01-14T15:31:01Z —
#5

I'm not Dart fan as of yet, who knows, maybe I'll never really dive into it.

And what I'd really like to try is TypeScript, if only there were some other tools beside Visual Studio that integrates it so well and that would allow me to really consume it, because is still so JavaScript-ish.

But I believe any of these two build up for the next JavaScript, and that's a very good thing. No need to worry, panic or get mad here.

felgall
—
2014-01-14T20:55:03Z —
#6

With the JavaScript Pattern Collection many of the conditional patters should be replaced by a switch statement.

Pullo
—
2014-01-14T21:06:22Z —
#7

Thanks felgall.

I've not had a chance to look at all of those patterns yet (there are a lot).Would you mind giving a concrete example of one or two which should be replaced.

system
—
2014-01-14T21:07:46Z —
#8

felgall said:

With the JavaScript Pattern Collection many of the conditional patters should be replaced by a switch statement.

... because of:

esthetics

readability

performance<snip/>

<snip/> I do expect some background information, tests, you know, stuff that makes people believe.

Pullo
—
2014-01-14T21:12:12Z —
#9

I too would be genuinely interested to hear this (hence my question), but please let's proceed in a polite fashion.

system
—
2014-01-14T21:21:54Z —
#10

Pullo said:

I too would be genuinely interested to hear this (hence my question), but please let's proceed in a polite fashion.

Sorry, Pullo, just reached a point I guess. Programming is not a cult, you're required to seek and to question, you're required to showcase and to prove.

When it comes to such differences, sometimes readability can trump performance, sometimes terseness can trump readability.

One can't just throw "should" because it's simply never true for everybody at once, but one should make a valid point as to why some use cases may benefit. Call it programmer's politeness.

In the case of if-else vs. switch, there is no relevant conclusion. The performance difference is too small, browser results are not one-sided and the agreement is to use whatever serves you best.

Some interesting points are that switch could be implemented as a look-up table, while if-else has the liberty to augment the conditional on each branch.

Finally, while one could emulate certain parts of the other, and while the reverse may also be true, there is no strict equivalence between if-else and switch.

markbrown4
—
2014-01-14T23:45:24Z —
#11

I'll be looking at react also, it's the first concept I know of that is challenging the idea of templates building a big string and updating the DOM directly.

I haven't looked at all the patterns but while all the ones I looked at that they say are bad basically are bad, not all of the ones they offer as better alternatives are necessarily the appropriate alternative. There are some quite good patterns there though as well.

Jeff_Mott
—
2014-01-15T02:59:55Z —
#13

felgall said:

Under the second link - conditionals ... Is better written using a lot less code as:

Admittedly the original author wasn't at all clear. I myself had to re-read it a few times to understand what he was trying to show with his code, especially since that long chain of if-else you quoted was, according to the author, a "binary search", which of course it isn't. I finally realized that the author was giving us a kind of before-and-after picture.

Admittedly the original author wasn't at all clear. I myself had to re-read it a few times to understand what he was trying to show with his code, especially since that long chain of if-else you quoted was, according to the author, a "binary search", which of course it isn't. I finally realized that the author was giving us a kind of before-and-after picture.

Even though the code I quoted was the before - the after should have been one of the two alternatives that I posted - the switch statement or the array and not the less efficient and much harder to read alternative that was provided.

felgall
—
2014-01-15T21:14:18Z —
#16

One further thought on that pattern for comparing a value to numbers.

If we know that the value will always be an integer between 0 and 10 then no comparisons are needed at all to return the appropriate one of the eleven values - you can do it in the return statement: