Check if object value exists and set new value for object key | Code optimization

Recently I have seen a code in the production that is
 if (!angular.isUndefined(newVal)) {
   if(!angular.isUndefined(newVal.min)){
     $scope.dataPoints.min = newVal.min;
   }
   if(!angular.isUndefined(newVal.max)){
     $scope.dataPoints.max = newVal.max;
   }
   if(!angular.isUndefined(newVal.yellowRangeMin)){
     $scope.dataPoints.yellowRangeMin = newVal.yellowRangeMin;
   }
   if(!angular.isUndefined(newVal.yellowRangeMax)){
     $scope.dataPoints.yellowRangeMax = newVal.yellowRangeMax;
   }
   if(!angular.isUndefined(newVal.redRangeMin)){

Ajax in React

Today I will share you the example that how ajax call can be done in react. You can choose any HTTP library but i will choose the axios. Here is the example this code will take reddit aww subreddit text and images from subreddt aww(cute pictures of animals). Here is the following code
import React from 'react';
import ReactDOM from 'react-dom';
import axios from 'axios';

class AjaxDemo extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            posts: []
        };
    }

    componentDidMount() {

Creating Basic Text Price Filter in React | Learning purpose

Recently,I have started learning the Reactjs and written small code that takes input value from user and return the values which are greater then number from that list. I have used the create-react-app boiler plate code. React bootstrap is also used in for it. Here is my code, code describes how to handle states and how can use react components with Es6 power capability.
import React from 'react';
import ReactDOM from 'react-dom';
import { Component } from 'react';
import './index.css';
import { Button } from 'react-bootstrap';
import { FormControl } from 'react-bootstrap';

Merging array of Objects in Javascript | Es6

We can use reduce function to merge array of objects in JavaScript, but you have to look out for a gotcha that is to provide an initialValue = {}; Here is the following code
function unproperMergeArrayofObjects(array){
    try{
       return array.reduce((a,b)=>Object.assign(a,b));
    }
    catch (err) {
        console.error(err);
        return null;
    }

}
function propermergeArrayofObject(array) {
    var initialValue={};
    return array.reduce((a,b)=>Object.assign(a,b),initialValue);
}

console.log('unproper',unproperMergeArrayofObjects([]));
var a={a:1};

Object Spread Operator | Cloning Object in Javascript

For cloning Javascript objects you can use following code,
var obj = { a: 1 };
var copy = Object.assign({}, obj);
console.log(copy); // { a: 1 }
A new term has been introduced the Object Spread Operator. It's not yet an official part of the language, but it did just recently reach Stage 3 proposal status, so it'll probably become official in ES2017 or ES2018. If you happen to be using the Create-React-App tool, that has the object spread Babel plugin already enabled.
var player = {score: 1, name: 'Jeff'};
var data=  {...player};

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;
}

Pages