PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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

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