Learn to identify them, make habits to avoid them

Image for post
Image for post
jscomplete.com/beginner-mistakes

Let me make one thing clear first. If you are a beginner programmer, this article is not meant to make you feel bad about the mistakes that you might be making but rather to make you aware of them, teach you to spot signs of them, and remind you to avoid them.

I have made these mistakes in the past and learned from each and every one of them. I am happy to have formed coding habits to help me avoid them. …


Image for post
Image for post

So you want to create a function in JavaScript?

You. Have. Options:

1 — Declaration Function

function sum(a, b) { return a + b; } 
// Can be named:
(function sum(a, b) { return a + b; });
// Or anonymous (AVOID):
(function(a, b) { return a + b; });
// Or assigned to a variable
const sum = function sum(a, b) { return a + b; })
// Single argument, one line return:
name => name.split(' ')
// Multi arguments, one line return:
(a, b) => a + b
// Single argument, full body:
name => { return name.split(' ')…


Image for post
Image for post
http://bit.ly/graphql-in-action

I am writing the GraphQL In Action book for Manning and 8 chapters (out of 11) has been published to MEAP. Below is the entire first chapter of the book. Feedback is welcome and very much appreciated.

This chapter covers

  • What GraphQL is and the design concepts behind it
  • How GraphQL is different from its alternatives, like REST APIs
  • The language and service parts of a GraphQL system
  • The advantages and disadvantages of GraphQL


It’s not about callback hell pyramid of doom

The difference between callbacks and promises in JavaScript is subtle but significant! Why exactly are we ditching callbacks in favor of promises?

How would you answer these questions in an interview??

The superiority of promises over callbacks is all about trust and control. Let me explain.

We generally need to use callbacks or promises when there is a slow process (that’s usually IO-related) that we need to perform without blocking the main program process. I once compared giving an asynchronous worker a callback function to giving a barista in a coffee shop your name to have it called when your order is ready. …


Image for post
Image for post

One of the projects I am involved in is hiring a senior JavaScript developer. To help with the opportunity, I tweeted this:

I certainly did not expect this much interest in a work opportunity about which I did not share many details!

A few hours after a single tweet, my inbox already had a couple of good candidates. After sifting through the initial set of replies received in the first 24 hours, I see at least 10 candidates who would be ideal for this job.

Why then is everyone saying that hiring coders is so damn hard?


The GraphQL schema language is great but…

Image for post
Image for post

The GraphQL schema language is great! It is certainly the best way to communicate anything about a GraphQL service. No wonder all documentations now use it!

The Schema Language

Imagine that you’re building a blog app (with GraphQL) that has “Articles” and “Comments” . You can start thinking about its API schema by basing it on what you plan for its UI. For example, the main page will probably have a list of articles and an item on that list might display a title, subtitle, author’s name, publishing date, length (in reading minutes), and a featured image. …


React developers love the modern features in JavaScript and use them extensively in their projects. In this guide, I’ll go over the most popular features that are usually used with React. Most of these features are modern to JavaScript but I’ll also talk about some older ones that are related and important for React.

This will NOT be a complete list of everything offered by the JavaScript language but rather the subset that I think will help you write better code for React.

Block scopes and the var/let/const keywords

A block scope is created with a pair of curly brackets. This happens every time you create an if-statement, for-statement, while-statement, etc. The only exception is the curly brackets you use with functions. …


Image for post
Image for post

Before I answer, if you‘re reading this article to pick a framework “to learn”, don’t. Read this article instead.

If you want to pick a framework to use (in an actual project), you may proceed :)

“Better” is really subjective. Better for what?

  • Scalability? Code written for all 3 frameworks can be scaled as much as needed if we’re talking about performance. Some frameworks will have smarter optimization every now and then, but eventually all frameworks will follow any good smart optimization that gets battle-tested out there.
  • Syntax and readability? You (person or team) be the judge! Try them all and feel which syntax you prefer. Many frameworks have different “ways” for you to use them so make sure to explore all options. …


Image for post
Image for post

A few weeks ago, I tweeted this interview question:

About half the replies to the Tweet were wrong. The answer is NOT V8 (or other VMs)!! While famously known as “JavaScript Timers”, functions like setTimeout and setInterval are not part of the ECMAScript specs or any JavaScript engine implementations. Timer functions are implemented by browsers and their implementations will be different among different browsers. Timers are also implemented natively by the Node.js runtime itself.

In browsers, the main timer functions are part of the Window interface, which has a few other functions and objects. That interface makes all of its elements available globally in the main JavaScript scope. This is why you can execute setTimeout directly in your browser’s console. …


Image for post
Image for post

Let me first define what I think a coding framework is because the word is debatable. I think a framework is a library that defines structures about every aspect or layer that can make the task of creating applications easier. By layers, I mean things like databases, models, controllers, views, presenters, networks, etc..

Frameworks try to solve most of the big and known problems that are usually encountered by their applications. They have built-in design decisions that you do not need to worry about. They also have carefully-crafted guidelines.

Good frameworks also have smart defaults and follow the convention over configuration concept. The leader of this is the Ruby on Rails framework, which is one of my favorites. In JavaScript land, the leading JavaScript frameworks out there are Angular and Ember. …

About

Samer Buna

Author for Pluralsight, O'Reilly, Manning, and LinkedIn Learning. Curator of jsComplete.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store