Format a Date in JavaScript

in JavaScript

My default choice for date formatting in JavaScript used to be Moment.js . It is a great library. A really complete solution to manage dates. I still use it server side. But 16.6k gziped, or 62.4 k with all the locales for one function ? That is way to much !

Continue reading

An alternative to if/else and switch in JavaScript

in JavaScript

I don’t intend to replace them for all their use case. It would be dumb. The alternative won’t change the way it works and its purpose is mostly code aesthetic.

Continue reading

Working in the DevTools, you don't use the console enough

in JavaScript

As front end developers, the browser console panel and the console API should be one of our primary tools. We all use the console.log() or console.dir() methods, but too few of us master the trace, time, profile and other magic methods that the console API provides. I will assume that you work with chrome and know how to access your console. I won’t write about the other pannels (Elements, Network…) but they are, of course, mandatory to master.

Continue reading

How and why the hoisting works in JavaScript

in JavaScript

Most of the decent fronts-end developers I met knew the basic principles of hoisting. How variables declarations are handled by JavaScript engines and why you may encounter what could appear as a quirk for a non JS developer. But fewer knew why it works that way and what happen under the hood. So I’ll try a basic explanation for these elements.

Continue reading

How to « find deep » and « get parent » in JavaScript nested objects with recursive functions and the reference concept (level beginner)

in JavaScript

Working with nested objects is frequent in JavaScript ; so I made this screen cast around this question. But the goal here is to help JavaScript beginners to understand how to build a simple recursive function and to get a better intuition about the reference system in JavaScript. The full text contents is in the post and you have also a fiddle to play with the code and see it in action.

Continue reading