PageRenderTime 61ms CodeModel.GetById 36ms RepoModel.GetById 1ms app.codeStats 0ms

/website/source/php/math/log.html

http://github.com/kvz/phpjs
HTML | 41 lines | 40 code | 1 blank | 0 comment | 0 complexity | 9427101f97f5a09b2e7cf8480b6e23ab MD5 | raw file
  1. ---
  2. warning: 'This file is auto generated by `npm run web:inject`, do not edit by hand'
  3. examples:
  4. - 'log(8723321.4, 7)'
  5. returns:
  6. - '8.212871815082147'
  7. dependencies: []
  8. authors:
  9. original by:
  10. - 'Onno Marsman (https://twitter.com/onnomarsman)'
  11. improved by:
  12. - 'Brett Zamir (https://brett-zamir.me)'
  13. notes: []
  14. type: function
  15. layout: function
  16. title: PHP's log in JavaScript
  17. description: >-
  18. Heres what our current JavaScript equivalent to <a
  19. href="https://php.net/manual/en/function.log.php">PHP's log</a> looks like.
  20. function: log
  21. category: math
  22. language: php
  23. permalink: php/math/log/
  24. alias:
  25. - /functions/php/log/
  26. - /functions/math/log/
  27. - /php/log/
  28. - /functions/log/
  29. ---
  30. {% codeblock lang:javascript %}module.exports = function log (arg, base) {
  31. // discuss at: https://locutus.io/php/log/
  32. // original by: Onno Marsman (https://twitter.com/onnomarsman)
  33. // improved by: Brett Zamir (https://brett-zamir.me)
  34. // example 1: log(8723321.4, 7)
  35. // returns 1: 8.212871815082147
  36. return (typeof base === 'undefined')
  37. ? Math.log(arg)
  38. : Math.log(arg) / Math.log(base)
  39. }
  40. {% endcodeblock %}