Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Fabric.js extend() Method

  • Last Updated : 31 Dec, 2020

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:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

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



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!