Find both open issues and closed issues using Field Aliases in Github GraphQL v4

Github GraphQL query to find the open and closed issues of Bootstrap using Field Aliases.

 

Output with Open and closed issues

 

JavaScript’s async await – ES2017 async/await syntax

The async function declaration defines an asynchronous function, which returns an AsyncFunction object.

The await operator is used to wait for a Promise returned by an async function.

If a Promise is passed to an await expression, it waits for the Promise’s resolution and returns the resolved value.

ES2017 async/await very basic example.

ES2017 async/await fetch data from url

Fetch data from Multiple urls

 

React native missing keys for items warning in FlatList (0.43.x)

gives me a warning: “VirtualizedList: missing keys for items, make sure to specify a key property on each item or provide a custom keyExtractor.”

 

ECMAScript 2015 (ES6) Default parameters – Quick reference

Default parameters

Default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed.

The above default parameter code is equivalent to the following code.

ECMAScript 2015 (ES6) Rest parameter – Quick reference

Rest parameters

The rest parameter syntax allows us to represent an indefinite number of arguments as an array with ... prefix.

Basic usage

In the above example, marks would collect the second argument of the function (because the first one is mapped to name) and all the consecutive arguments.

Difference between rest parameters and the arguments object

There are three main differences between rest parameters and the arguments object:

  • rest parameters are only the ones that haven’t been given a separate name, while the arguments object contains all arguments passed to the function;
  • the arguments object is not a real array, while rest parameters are Array instances, meaning methods like sort, map, forEach or pop can be applied on it directly;
  • the arguments object has additional functionality specific to itself (like the callee property).

Example

ECMAScript 2015 (ES6) Arrow functions – Quick reference

Arrow functions

An arrow function expression has a shorter syntax => compared to function expressions.

Arrow functions are always anonymous (Functions declared dynamically at runtime called Anonymous functions. Anonymous functions don’t have a name and not hoisted). The examples are below

Function without any parameters

Function with 1 parameter

Function with more than 2 parameters

this reference

An arrow function does not create its own this context, so this has the original meaning from the enclosing context.

ECMAScript 2015 (ES6) Let & Constants – Quick reference

Let

The let statement declares a block scope local variable, optionally initializing it to a value.

Redeclaring the same variable within the same function or block scope raises a SyntaxError.

In ECMAScript 2015, let will hoist the variable to the top of the block. However, referencing the variable in the block before the variable declaration results in a ReferenceError.

let and const are hoisted (like var and function), but there is a period between entering scope and being declared where they cannot be accessed. This period is the temporal dead zone (TDZ).

Still the above statement throwing error. Because of TDZ

Constants

Constants are block-scoped (not function level scope like var).

The value of a constant cannot change through re-assignment, and it can’t be redeclared.

The const declaration creates a read-only reference to a value.

Declaration and Usage

Scope

Block scope level variable let Declaring and hoisting – ES6

let declaration and usage

The let statement allows to create and initialize variables inside the block scope. This might be function, statements (if, for, etc) or expression. By default a declared yet not initialized variable has undefined value like as var declaration.

let is introduced in ECMAScript 6, which allows to keep the code more encapsulated on a block level.

Try in JS Bin

let Hoisting

Variables declared with let are hoisted to the top of the block. But when the variable is accessed before declaration, JavaScript throws an error: ReferenceError: <variable> is not defined.

Try in JS Bin

Redeclaring the same variable within the same function or block scope raises a SyntaxError.