If you’re thinking of implementing AWS Simple Email Service for your product, you might find out that you need a flow to handle email bounces and complaints before AWS approves your service quota increase and take your SES account out of sandbox mode.

This requirement assures SES maintains a high reputation for only delivering mail people want and thereby maintaining a high deliverability for legitimate mail.

What exactly are email bounces and complaints?

Bounce email happens when an is returned to the sender because it cannot be delivered for some reason.

Complaints are reports made by email recipients against emails…


ughh… :(((

In one of my recent projects we encountered many images which were missing from our S3 bucket. When I see something like this it just makes me sick 😫.

<img> provides us with two events, onLoad and onError. We can use these two keep track of the status of the image.

onError is called when our image has failed to load, and we can set src to our preferred fallback image.

onLoad is called when our image loaded successfully, nothing for us to do here.

import React from "react";
import PropTypes from "prop-types";

class Image extends React.Component {
constructor(props) {…

  • Async/Await is a new way to write asynchronous code. Previous options for asynchronous code are callbacks and promises.
  • Async/await is built on top of promises. It cannot be used with plain callbacks or node callbacks.
  • Async/await makes asynchronous code look and behave a little more like synchronous code.

Note that await may only be used in functions marked with the async keyword. It works similarly to generators, suspending execution in your context until the promise settles. If the awaited expression isn’t a promise, its casted into a promise.

async await allows us to perform the same thing we accomplished using…


A generator is a function which can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances.

Generators in JavaScript are a very powerful tool for asynchronous programming as they mitigate the problems with callbacks, such as Callback Hell and Inversion of Control.

This pattern is what async functions are built on top of.

For creating a generator function, we use function * syntax instead of just function.

Calling a generator function does not execute its body immediately; an iterator object for the function is returned instead. When the iterator’s next() method is called, the generator…


Promises are one of the most exciting additions to JavaScript ES6. Promises are a pattern that greatly simplifies asynchronous programming by making the code look synchronous and avoid problems associated with callbacks.

Prior to ES6, we used bluebird or Q. Now we have Promises natively.

A Promise is an object that is used as a placeholder for the eventual results of a deferred (and possibly asynchronous) computation.

The resolve and reject are functions themselves and are used to send back values to the promise object.

const myPromise = new Promise((resolve, reject) => {
if (Math.random() * 100…

from

const inventory = [
{name: 'mars', quantity: 2},
{name: 'snickers', quantity: 3}
];
console.log(Array.from(inventory, item => item.quantity + 2)); // [4, 5]

of

Array.of("Twinkle", "Little", "Star"); // returns ["Twinkle", "Little", "Star"]

find

const inventory = [
{name: 'mars', quantity: 2},
{name: 'snickers', quantity: 3}
];
console.log(inventory.find(item => item.name === 'mars')); // {name: 'mars', quantity: 2}

findIndex

const inventory = [
{name: 'mars', quantity: 2},
{name: 'snickers', quantity: 3}
];
console.log(inventory.findIndex(item => item.name === 'mars')); // 0

fill method takes up to three arguments value, start and end. …


.includes( )

var string = 'string';
var substring = 'str';

console.log(string.indexOf(substring) > -1);

Instead of checking for a return value > -1 to denote string containment, we can simply use .includes() which will return a boolean:

const string = 'string';
const substring = 'str';

console.log(string.includes(substring)); // true

.repeat( )

function repeat(string, count) {
var strings = [];
while(strings.length < count) {
strings.push(string);
}
return strings.join('');
}

In ES6, we now have access to a nicer implementation:

// String.repeat(numberOfRepetitions)
'str'.repeat(3); // 'strstrstr'

You can find a more complete ES6 cheetsheet on my Github page.

P.S. If you ❤️ this, make sure to follow me on Twitter, and share this with your friends 😀🙏🏻


A Set is a collection for unique values. The values can be primitives or object references.

let set = new Set();
set.add(1);
set.add('1');
set.add({ key: 'value' });
console.log(set); // Set {1, '1', Object {key: 'value'}}

Most importantly is that it does not allow duplicate values, one good use if to remove duplicate values from an array:

[ ...new Set([1, 2, 3, 1, 2, 3]) ] // [1, 2, 3]

Iteration using built-in method forEach and for..of:

// forEach
let set = new Set([1, '1', { key: 'value' }]);
set.forEach(function (value) {
console.log(value); …

Map

A Map is a data structure allows to associate data to a key.

Before it’s intruduction in ES6, people generally used objects as maps, by associating some object or value to a specific key value:

const person = {}
person.name = 'John'
person.age = 18

console.log(person.name) //John
console.log(person.age) //18

Map example:

const person = new Map()

person.set('name', 'John')
person.set('age', 18)

const name = person.get('name')
const age = person.get('age')

console.log(name) //John
console.log(age) //18

The Map also provide us with methods to help us manage the data.

delete() method - deletes an item from a map by key:

person.delete('name')

clear() method …


Prior to ES6, we used libraries such as Browserify to create modules on the client-side, and require in Node.js. With ES6, we can now directly use modules of all types (AMD and CommonJS).

Exporting in CommonJS

module.exports = 1;
module.exports = { foo: 'bar' };
module.exports = ['foo', 'bar'];
module.exports = function bar () {};

Exporting in ES6

Named Exports:

export function multiply (x, y) {
return x * y;
};

As well as exporting a list of objects:

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

function multiply (x, y) {
return x * y;
};

export { add, multiply };

Default export:

Mihai Serban

👨🏻‍💻 Software Engineer | 🐶❤️ | 🏔 Traveler | Passionate about #swift #objectivec #javascript #graphql #reactjs #nodejs

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