Skip to content
Related Articles

Related Articles

Fabric.js extend() Method
  • Last Updated : 31 Dec, 2020
GeeksforGeeks - Summer Carnival Banner

The extend() method is used to create a copy of all the properties of the source objects over the destination object and return the destination object. Do not clone or extend fabric.Object subclasses. This is mostly for internal use and has extra handling for fabricJS objects, it skips the canvas property in deep cloning.

Syntax:

extend(destination, source)

Parameters: This method accepts two parameters as mentioned above and described below:

  • destination: This parameter says where to copy to.
  • source: This parameter says where to copy from.

Return Value: This method returns a copy of all of the properties of the source objects over the destination object, and return the destination object.

Example 1:



Javascript




<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
  
    <script type="text/javascript" src=
    </script>
  
    <script type="text/javascript" src=
    </script>
</head>
  
<body>
    <script type="text/javascript">
        var obj1 = {
            key1: 'Geeks',
        };
  
        var obj2 = {
            key2: 'GeeksforGeeks',
        };
  
        console.log(fabric.util
            .object.extend(obj1, obj2));
    </script>
</body>
  
</html>

Output:

{"key1": "Geeks", "key2": "GeeksforGeeks"}

Example 2:

Javascript




<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
  
    <script type="text/javascript" src=
    </script>
    <script type="text/javascript" src=
    </script>
</head>
  
<body>
    <script type="text/javascript">
        var obj1 = {
            key1: 'GFG', key2: 'gfg',
        };
  
        var obj2 = {
            key3: '5', key4: '10',
        };
  
        console.log(fabric.util
            .object.extend(obj1, obj2));
    </script>
</body>
  
</html>

Output:

{"key1": "GFG", "key2": "gfg", "key3": "5", "key4": "10"}

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :