![]() |
VOOZH | about |
The forget() function as the name suggest forgets/remove an item from the collection using its key. In JavaScript, the array is first converted to a collection and then the function is applied to the collection.
Syntax:
data.forget('key')
Parameters: This function accept a single parameter as mentioned above and described below:
Return value: Return the collection except the key's value that was mentioned.
Below examples illustrate the forget() function in collect.js
Example 1: Here in this example, we take a collection and then using the forget() function we return the collection without the key element we forget.
Output:
{ name: 'Jhon' }
Example 2: Same thing we have done here as above example.