background preloader

JavaScript - General

Facebook Twitter

JavaScript async and await in loops. Why don’t we use var anymore? – Coding Sam. If you used to code in Javascript in the old days, you used the var keyword a lot.

Why don’t we use var anymore? – Coding Sam

There was no other way to declare a variable. It was really simple. The only thing you needed to do was just something like this: var x = 3; var y = 'hello'; // etc... Since ES6, there are two new keywords, const and let. Const x = 2; Finding Your Way With .Map() Let’s explore Slice(), Splice() & Spread Syntax(…) in JavaScript. How to rewrite a callback function in Promise form and async/await form in JavaScript. “You should really use Promises or async/await here to make this more readable” How many times have you posted some code snippet when trying to get an answer to your question, and someone ends up pestering you about this?

How to rewrite a callback function in Promise form and async/await form in JavaScript

Now, on top of whatever problem you already have with your code, you have another thing you need to learn and “fix”… Or what about dealing with refactoring an existing, callback-based codebase at work? When to use var vs let vs const in JavaScript. JavaScript arrow functions for beginners – Tassia Paschoal. I have recently started diving into the new features in ECMASCRIPT6 and wanted to share with you one of my favorite features so far.

JavaScript arrow functions for beginners – Tassia Paschoal

Arrow functions seem to be the most popular new feature for good reasons. They provide a concise way to write functions in JavaScript while also simplifying function scope. Not to mention, most all modern languages have this syntax; Java and C# call them lambda expressions and they behave very similarly. JavaScript. JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript is a prototype-based, multi-paradigm, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles. Read more about JavaScript. This section is dedicated to the JavaScript language itself, and not the parts that are specific to Web pages or other host environments.

For information about APIs specific to Web pages, please see Web APIs and DOM. Getting Started. This article is partially or completely unfinished.

Getting Started

You are welcome to create pull requests to help completing this article. Node.js Then: var Promise = require("bluebird"); Alternatively in ES6 import * as Promise from 'bluebird'; Browsers (See also Installation.) Rethinking JavaScript: The complete elimination and eradication of JavaScript's this. If this is so difficult to reason about, why don't we just stop using it?

Rethinking JavaScript: The complete elimination and eradication of JavaScript's this.

Seriously. Why. don't. we. just. stop. using. it.? JavaScript ES6+: var, let, or const? – JavaScript Scene. Perhaps the most important thing you can learn to be a better coder is to keep things simple.

JavaScript ES6+: var, let, or const? – JavaScript Scene

In the context of identifiers, that means that a single identifier should only be used to represent a single concept. Sometimes it’s tempting to create an identifier to represent some data and then use that identifier as a temporary place to store values in transition from one representation to another. For instance, you may be after a query string parameter value, and start by storing an entire URL, then just the query string, then the value. This practice should be avoided. It’s easier to understand if you use one identifier for the URL, a different one for the query string, and finally, an identifier to store the parameter value you were after. Flavio Copes. CodeSandbox. ES6 — Map vs Object — What and when? – Frontend Weekly. The concepts What is Map?

ES6 — Map vs Object — What and when? – Frontend Weekly

Map sounds very simple, doesn’t it? We see or hear about it almost everyday, let’s say World map, Street map, etc…. So what is exactly Map? Map is a data collection type (in a more fancy way — abstract data structure type), in which, data is stored in a form of pairs, which contains a unique key and value mapped to that key. You may recognize by now one common thing about all examples mentioned above — they are used for looking up something (can be a country — for World map, a street name — Street map, etc…). That’s right, Map is mainly used for fast searching and looking up data. JavaScript: Arrow Functions for Beginners. What is "this" in JavaScript? Modern JavaScript Explained For Dinosaurs – Node.js Collection. Learning modern JavaScript is tough if you haven’t been there since the beginning.

Modern JavaScript Explained For Dinosaurs – Node.js Collection

The ecosystem is growing and changing so rapidly that it’s hard to understand the problems that different tools are trying to solve. I started programming in 1998 but only began to learn JavaScript seriously in 2014. At the time I remember coming across Browserify and staring at its tagline: ES6 Cool stuffs — A big fat Arrow – Frontend Weekly. As usual, let’s do a quick brief on old concepts about function in JS for the start.

ES6 Cool stuffs — A big fat Arrow – Frontend Weekly

Function in JS Every function in JS (before ES6) can be declared with function operator syntax function HelloWorld(){ console.log('Hello World');} HelloWorld(); //'Hello World' Or can be declared as non-method functions using function key word inside an expression let sayHello = function() { console.log('Hi there, do you come here often? A Beginner’s Guide to Arrow Functions in ES6: Part 1. Arrow functions are always anonymous functions.

A Beginner’s Guide to Arrow Functions in ES6: Part 1

Before describing an anonymous function, let’s first answer the question, “What is a named function?” // In ES5 a named function can be written as follows:function myFavFood(food) { console.log(`My favorite food is ${food}! `);} // myFavFood is the name of the function. // Calling this in the console:myFavFood('pizza'); JavaScript — WTF is ES6, ES8, ES 2017, ECMAScript… ? 7 bad excuses for not using TypeScript. Typescript has come a long way since its inception over six years ago and is being adopted by leading web companies. While there may be good reasons to avoid using it, chances are your excuses for not using TypeScript are just bad. In this article, I’ll cover common concerns like the learning curve, tooling, development speed, sustainability and standards compliance. 1.

TypeScript — JavaScript with superpowers.