• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 23. Cookies and Creating Your Own Objects

Chapter 23. Cookies and Creating Your Own Objects


In this chapter, we’ll take a look at two topics near and dear to the JavaScript programmer’s heart: using cookies and creating your own objects.

Everyone knows about cookies—they’re those data items that you can store on someone’s computer. You can store everything from the users’ name (if they give it to you) to the current items they’ve purchased and how much their total is. Using cookies is easier than you might think in JavaScript, and we’ll take a look at how to work with them in this chapter. We’ll see not only how to create and store a cookie, but also what’s involved in reading them at a later time. We’ll also see how to specify when a cookie expires—that is, when the browser should delete it. And we’ll see how to delete a cookie ourselves.

We’ll also take a look at creating custom objects in this chapter. JavaScript uses objects, but it’s not truly object-oriented, because it doesn’t support all those elements that are necessary for true object-oriented programming (OOP), such as classes, inheritance, polymorphism, and more.

Instead, some people consider JavaScript object-based. That is, instead of supporting all the OOP formality, JavaScript enables you to work with many preexisting objects, such as the built-in objects such as String, Array, Boolean, and so on, as well as gives you access to browser objects such as the document, navigator, and window objects.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint