Skip to content

Add optional default value for get() #75

Description

@Kangaroux

Would be nice to have an optional default parameter for the get function. If the cookie is undefined then the default would be returned instead.

var c = Cookies.get("some-cookie");

if(typeof c === "undefined") {
  c = "default value";
}

vs.

var c = Cookies.get("some-cookie", "default value");

Note that the current implementation uses undefined as the default, so there really is no performance hit from doing this.

https://github.com/ScottHamper/Cookies/blob/master/src/cookies.js#L41

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions