A Bookmarklet Calculator
If you think about it, it’s really a bit too difficult to do a full-fledged calculator with buttons and a running value on just one long line of code. However, you can use a bookmarklet like Script 17.11 to do fairly complex calculations, using JavaScript’s built-in Math functions, as described in Table 17.1.
Function | Description |
abs | Absolute value |
sin, cos, tan | Standard trigonometric functions; arguments in radians |
acos, asin, atan | Inverse trigonometric functions; return values in radians |
exp, log | Exponential and natural logarithm, base e |
ceil | Returns least integer greater than or equal to argument |
floor | Returns greatest integer less than or equal to argument |
min | Returns lesser of two arguments ... |
Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.