Lodash _.assign Method Example

The _.assign method is the equivalent of the spread operator from ES6. It’s pretty easy to understand, it assigns properties of one or many objects to a source object.
Learn Lodash JS at Lodash JS Tutorial with Examples.

Lodash _.assign Method Example

<!DOCTYPE html>
    <title>Lodash Tutorial</title>
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>
    <script type="text/javascript">
        var foo = {
            a: "a property"
        var bar = {
            b: 4,
            c: "an other property"

        var result = _.assign({
            a: "an old property"
        }, foo, bar);

{"a":"a property","b":4,"c":"an other property"}


Free Spring Boot Tutorial - 5 Hours Full Course

Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course