Open In App

Fabric.js removeFromArray() Method

Last Updated : 03 Mar, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The removeFromArray() method is used to remove a value from the specified array of values.

Syntax:

removeFromArray(array, value)

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

  • array: This parameter holds the specified array of values.
  • value: This parameter holds the value which is going to be removed from the array.

Return Value: This method returns the array of remaining values.

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">
 
        // Calling removeFromArray() function over
        // some specified arrays and values to be removed
        console.log(fabric.util.removeFromArray([1, 2, 3], 2));
        console.log(fabric.util.removeFromArray([1, 2, 3], 1));
        console.log(fabric.util.removeFromArray([1, 2, 3], 0));
    </script>
</body>
 
</html>


Output:

[1,3]
[2,3]
[1,2,3]

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">
 
        // Specifying some arrays
        var array1 = [2, 4, 6];
        var array2 = [1, 3, 4];
 
        // Specifying some values
        var value1 = 2;
        var value2 = 4;
 
        // Calling removeFromArray() function over the
        // above specified arrays and values to be removed
        console.log(fabric.util.removeFromArray(array1, value1));
        console.log(fabric.util.removeFromArray(array2, value2));
    </script>
</body>
 
</html>


Output:

[4,6]
[1,3]


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads