The numerous techniques to set and update a cookie in JavaScript were covered in the preceding section. Apart from that, we may remove a cookie using JavaScript. We can see all of the options for deleting a cookie here.
You may remove a cookie by changing its expiration date to any point in the past and giving it an empty value.
Here's how we'd go about deleting the userId cookie from earlier
(reload page for output)