
Biweekly dose ๐ of JavaScript wisdom delivered in bite-sized ๐ฎ tweets. Written by @superkarolis ๐จโ๐ป
Earth ๐
Joined July 2018
- Tweets48
- Following88
- Followers316
- Likes322
console.log() is undoubtedly the most common way to debug #JavaScript applications. However, #googlechrome developer tools have great debugging tools as well, primarily breakpoints which you can use to track the state of variables. Check out more medium.com/datadriveninvestoโฆ ๐
Expression produces a value and can be written wherever a value is expected. On the other hand, statement performs an action without producing a value. Wherever #JavaScript expects a statement, you can also write an expression. Such a statement is called an expression statement.
When receiving data from a web server, data is always a string. You can pass such data JSON.parse() and get a JavaScript object. JSON.stringify() is a reverse method and converts JSON to a string. These methods in combination can be used to efficiently clone objects. #javascript
JSON (#JavaScript Object Notation) is a popular format for structuring data. It is based on a subset of JavaScript language, is alternative to XML and is mostly used to transmit data between a server and web client. It is made up of key/value pairs. Below is an example of JSON ๐
While a lot of us have started making websites using jQuery, there is really no need to still use it when developing for the the modern web. Check out youmightnotneedjquery.com/ for examples on how to replace common jQuery code snippets and see some examples below ๐ #javascript
LHS stands for left-hand side, and RHS stands for right-hand side. LHS references are located on the left hand side of the = assignment operator. RHS references are located on the right-hand side of the of the = assignment operator or implied when there is no LHS reference.
While there are no true named and optional arguments in #JavaScript, it is possible to get functionally equivalent behavior by using #ES6 destructuring. This pattern is great because it allows you to explicitly define what you are expecting to receive and set up the defaults.
#ES6 and #ECMAScript2015 (or #ES2015), are all different names for the same thing. ES6 was the popularized name prior to new language release. However, the ECMAScript committe decided to use ES2015 instead as the official name to reflect the year of release.
In #javascript, parameters of functions default to undefined. Since #ES6 came out, default function parameters became part of the language specification. They allow formal parameters to be initialized with default values if no value or undefined is passed.
Modules refer to small units of independent, reusable code. There are several different module systems in #JavaScript - CommonJS, Asynchronous Module Definition (AMD) and ECMAScript 6 modules (Native JavaScript). Let's have a look at each ๐
Lighthouse by Google is a great resource for developers interested in web performance and quality. To put it short, it is an automated tool for auditing performance, accessibility, progressive web apps, SEO and more. It's available on Chrome Dev Tools ๐ developers.google.com/web/toโฆ
By using destructuring in #ES6 it is possible to swap two regular variables or elements of an array in a much more efficient manner in terms of lines of codes than in previous versions of #JavaScript. See the example ๐
Linting is the process of checking the source code for programmatic as well as stylistic errors. This is most helpful in identifying various mistakes that are made during coding. Check out this comparison of linting tools ๐ย codeburst.io/javascript-lintโฆ #javascript #programming
Test-driven development #TDD is an approach to development that consists of writing tests, followed by production code, and refactoring as needed. The tests are written initially, and the developer writes code to fulfill the requirements of the test so they pass. #javascript
Destructuring in #JavaScript #ES6 is a convenient way of extracting values from objects and arrays. Object destructuring often consists of a basic assignment where variable names match those of object keys. Array destructuring works by mapping variables based on the array index.
Math in #JavaScript is a built-in object that has properties and methods for mathematical constants and functions, all of which are static. Note that many #math functions have a precision that's implementation-dependent and thus results may differ on various browsers and OSes.
Closure in #JavaScript is when a function is able to access its lexical scope even when that function is executing outside its lexical scope. Closure has three scope chains: its own scope, outer functionโs scope, and global scope. They make the code more clear and readable.
#JavaScript Throttling vs debounce. Throttling delays executing a function. It reduces the notifications of an event that fires multiple times. Debouncing ensures that one notification is made for an event that fires multiple times. See it visually ๐ demo.nimius.net/debounce_thrโฆ
#ES6 functions are also called fat-arrow functions due to => being used in the syntax. Fat-arrow functions do not have their own binding and instead retain the context of their enclosing lexical context. They also have cool features like implicit returns and short-hand syntax.















