Safely get a nested value inside an object

Today, I will share how could you safely get a nested value rather using hacks like this
const nestedVal = (
  obj &&
  obj.lorem &&
  obj.lorem.ipsum &&
You could use code like this
function get(obj, path) {
    const valueFromPath = path.split('.').reduce((previousValue, pathItem) => {
        if (typeof previousValue === 'undefined') return; // Will finish the rest of the iterations unfortunately :(

        const nextValue = previousValue[pathItem];

        return nextValue;
    }, obj);

    return valueFromPath;

Named Import Vs Single default export in modules es6

JavaScript has had modules for a long time. However, they were implemented via libraries, not built into the language. ES6 is the first time that JavaScript has built-in modules.
ES6 modules are stored in files. There is exactly one module per file and one file per module. You have two ways of exporting things from a module. These two ways can be mixed, but it is usually better to use them separately.

Multiple named exports

There can be multiple named exports:
//------ lib.js ------
export const sqrt = Math.sqrt;
export function square(x) {
    return x * x;

Let in Es6

let allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used. This is unlike the var keyword, which defines a variable globally, or locally to an entire function regardless of block scope.

Variables declared by let have as their scope the block in which they are defined, as well as in any contained sub-blocks . In this way, let works very much like var. The main difference is that the scope of a var variable is the entire enclosing function:
function varTest() {
  var x = 1;
  if (true) {