In this blog post, I take a different approach to explaining this in JavaScript: I pretend that arrow functions are the real functions and ordinary functions a special construct for methods. I think it makes this easier to understand – give it a try.

Two kinds of functions

In this post, we focus on two different kinds of functions:

Ordinary functions: function () {}

Arrow functions: () => {}

An ordinary function is created as follows.

function add(x, y) { return x + y; }

Each ordinary function has the implicit parameter this that is always filled in when it is called. In other words, the following two expressions are equivalent (in strict mode).

Rust WebAssembly transform for Browserify. Because this is an unstable rust feature, at the time of writing it relies on wasm-gc to be available from the command line. See Installation for instructions on how to install. Probably also doesn't work on Windows.

Because this feature is experimental in Rust, this module should be considered similarly.

When React came out I was really amazed with its easiness of use and learning curve. When I first started learning React I wasn’t aware of the fact that React is just a library and not a fully fledged framework. I wasn’t aware that I would need to make all decisions about architecture and what exactly I would need to use in order to solve some common tasks. Other frameworks would give you solutions and architecture out of the box which is not the case with React lib. Yes, someone might say that I was naive and dumb but that naivety and my will to learn new things pushed me forward and made me a better developer and decision maker.

Update 1: Due to a lot of polarizing comments (like loved or hated the article) I just want to be clear that shorthand are useful sometimes and sometimes not, depends on which context, don’t take shorthand code as the best of any situation!

I’ve made this post as a vital source of reference for learning shorthand JavaScript coding techniques that I have picked up over the years. To help you understand what it going on I have included the longhand versions to give some coding perspective on the shorts.

When creating new variables sometimes you want to check if the variable you’re referencing for it’s value isn’t null or undefined. I would say this is a very common check for JavaScript coders.

Knowing your tools can make a significant difference when it comes to getting things done. Despite JavaScript's reputation as being difficult to debug, if you keep a couple of tricks up your sleeve errors and bugs will take less time to resolve.

We've put together a list of 14 debugging tips that you may not know, but might want to keep in mind for next time you find yourself needing to debug your JavaScript code!

Let's get to it.

Most of these tips are for Chrome Inspector and Firefox, although many will also work with other inspectors.

1. ‘debugger;’

After console.log, 'debugger;' is my favorite quick and dirty debugging tool. Once it's in your code, Chrome will automatically stop there when executing. You can even wrap it in conditionals, so it only runs when you need it.

With the recent release of Node.js 8.5, three very exciting new features landed in the Node.js core. In the short blogpost, you are going to learn about them!

ECMAScript Modules in Node.js!

One of the most requested features of Node.js was to provide support for ESM. What it means is that you can now use the import keyword, without transpiling your code. So from now on, you can run snippets like these:

import fs from 'fs'

The only two things you have to pay attention to is to name your file with the mjs extension and to run Node.js with the --experimental-modules flag.

That’s the basic idea of stepping through code. If you look at the code in get-started.js, you can see that the bug is probably somewhere in the updateLabel() function. Rather than stepping through every line of code, you can use another type of breakpoint to pause the code closer to the location of the bug.

Line-of-code breakpoints are the most common type of breakpoint. When you’ve got a specific line of code that you want to pause on, use a line-of-code breakpoint. Try it now:

Look at the last line of code in updateLabel(), which looks like this:

One of the most basic debugging tools in JavaScript is console.log(). The console comes with several other useful methods that can add to a developer’s debugging toolkit.

You can use the console to perform some of the following tasks:

Output a timer to help with simple benchmarking

Output a table to display an array or object in an easy-to-read format

Apply color and other styling options to the output with CSS

The console object gives you access to the browser’s console. It lets you output strings, arrays, and objects that help debug your code. The console is part of the window object, and is supplied by the

Or How I Learned to Stop Writing Callback Functions and Love Javascript ES8.

Sometimes modern Javascript projects get out of hand. A major culprit in this can be the messy handling of asynchronous tasks, leading to long, complex, and deeply nested blocks of code. Javascript now provides a new syntax for handling these operations, and it can turn even the most convoluted asynchronous operations into concise and highly readable code.

Background

First a brief bit of history. In the late 1990s, Ajax was the first major breakthrough in asynchronous Javascript. This technique allowed websites to pull and display new data after the HTML had been loaded, a revolutionary idea at a time when most websites would download the entire page again to display a content update. The technique (popularized in name by the bundled helper function in jQuery) dominated web-development for all of the 2000s, and Ajax is the primary technique that websites use to retrieve data today, but with XML largely substituted for JSON.

ES2017 was finalized in June, and with it came wide support for my new favorite JavaScript feature: async functions! If you've ever struggled with reasoning about asynchronous JavaScript, this is for you. If you haven't, then, well, you're probably a super-genius.

Async functions more or less let you write sequenced JavaScript code, without wrapping all your logic in callbacks, generators, or promises. Consider this:

Note: This is part of the “Composing Software” series on learning functional programming and compositional software techniques in JavaScript ES6+ from the ground up. Stay tuned. There’s a lot more of this to come!< Previous | << Start over at Part 1 | Next >

A factory function is any function which is not a class or constructor that returns a (presumably new) object. In JavaScript, any function can return an object. When it does so without the new keyword, it’s a factory function.

Factory functions have always been attractive in JavaScript because they offer the ability to easily produce object instances without diving into the complexities of classes and the

Are you confused by the this keyword in JavaScript? It confuses everyone in the beginning, so don’t worry about it. You’re not alone.

But that doesn’t mean you can go on without understanding this forever. It is used so much in JavaScript and in tutorials everywhere that you need to grasp what this is sooner or later. Once you understand this, you’ll realize that it’s much simpler than you think it is.

By the end of this article, you would have demystified this for yourself. You’ll know what it is, what it does and how to use it.

So, what is this?

this is a keyword whose value changes depending on how a function gets called. There six different ways where

One of the most basic debugging tools in JavaScript is console.log(). The console comes with several other useful methods that can add to a developer’s debugging toolkit.

You can use the console to perform some of the following tasks:

Output a timer to help with simple benchmarking

Output a table to display an array or object in an easy-to-read format

Apply color and other styling options to the output with CSS

The console object gives you access to the browser’s console. It lets you output strings, arrays, and objects that help debug your code. The console is part of the window object, and is supplied by the

This really is a must read for any JavaScript-based developer. I have written this article as a vital source of reference for learning shorthand JavaScript coding techniques that I have picked up over the years. To help you understand what is going on I have included the longhand versions to give some coding perspective.

June 14th, 2017: This article was updated to add new shorthand tips based on ES6. If you want to learn more about the changes in ES6, sign up for SitePoint Premium and check out our screencast A Look into ES6

1. The Ternary Operator

This is a great code saver when you want to write an if..else statement in just one line.

Learning new syntax is a weird thing. Most of us pick up the bare minimum that we need to be productive, and then occasionally when watching a friend/colleague/instructor code, we stumble upon new tricks that make us wonder how we survived without them.

The below list is 5 such little shortcuts that will make your coding life a little faster.

As always, if this article is useful to you, please recommend and share!

JavaScript has progressed a ton in the recent years. If you’re learning JavaScript in 2017 and you haven’t touched ES6, you’re missing out on an easier way to read and write JavaScript.

Don’t worry if you’re not a master at JavaScript yet. You don’t need to be awesome at JavaScript to take advantage of the added bonuses ES6 gives you. In this article, I want to share with you eight ES6 features I use daily as a developer to help you ease into the new syntax.

A list of ES6 features

First off, ES6 is a huge update to JavaScript. Here’s a big list of features if you’re curious about what’s new, thanks to

This is part 2 of a series of posts where I explore the tradeoffs between Javascript classes and the closure pattern (known frequently also as the factory class pattern), two patterns that can be used as substitutes for each other. The series is in three parts

I will compare both memory efficiency of the two patterns, and then CPU efficiency. But first:

To appreciate this post, you should be familiar with Javascript’s object prototype. I recommend this very detailed overview if you are not. Salient details:

You can make multiple objects with the same prototype using the new keyword.

Before we get to named capture groups, let’s take a look at numbered capture groups; to introduce the idea of capture groups.

Numbered capture groups

Numbered capture groups enable you to take apart a string with a regular expression.

Successfully matching a regular expression against a string returns a match object matchObj. Putting a fragment of the regular expression in parentheses turns that fragment into a capture group: the part of the string that it matches is stored in matchObj.

Prior to this proposal, all capture groups were accessed by number: the capture group starting with the first parenthesis via

Our journey began on an April morning at 4 AM. I didn’t think it was possible for people to be awake at such an ungodly hour, but we lived through it. There was only one issue. The morning of our flight, this happened.

In case it’s not clear, that’s snow. Lots of snow. Getting to the airport on time was quite a ride. People were telling me to pack my ice skates cause that’s the only way I would make it safely there. All things considered, we did make it on time and some of us even got over a lifetime fear of getting on a plane (and surviving the process).

After a quick 5–6 hour layover in Munich, where we enjoyed the incredible view of the airport waiting room and some pretzels we got to Amsterdam.

Godzilla is a ES2015 to Go source code transpiler and runtime that is intended to be a near drop-in replacement for Node.js. It compiles ES2015 source code to Go source code which is then compiled to native code. The compiled Go source code is a series of calls to the Godzilla runtime, a Go library serving a similar purpose to Node.js.

Godzilla parses ES2015 source code with the awesome babylon. That means at the moment Node.js is required for compilation. As Godzilla becomes mature, babylon will be compiled to Go source code using Godzilla itself so that the Node.js dependency can be dropped.

Objection.js is an ORM for Node.js that aims to stay out of your way and make it as easy as possible to use the full power of SQL and the underlying database engine while keeping magic to a minimum.

Objection.js is built on an SQL query builder called knex. All databases supported by knex are supported by objection.js. SQLite3, Postgres and MySQL are thoroughly tested.

What objection.js gives you:

What objection.js doesn’t give you:

A custom query DSL. SQL is used as a query language.

Automatic database schema creation and migration. For simple things it is useful that the database schema is automatically generated from the model definitions, but usually just gets in your way when doing anything non-trivial. Objection.js leaves the schema related things to you. knex has a great