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

Chapter 8. Math > Example: A Logarithm Function for Multiple Bases

Example: A Logarithm Function for Multiple Bases

In Chapter 2, “Function(),” I replaced one of the Math object's methods with an alternative as the example. However, the Math object itself can contain any additional properties and methods you care to create directly.

One of my favorites is a logarithm function that responds with a different base than Euler's number, e. For instance, log10 1,000 = 3 because 103 = 1,000. JavaScript does not provide this functionality natively (see Listing 8.2).


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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