/website/source/php/math/log.html
HTML | 41 lines | 40 code | 1 blank | 0 comment | 0 complexity | 9427101f97f5a09b2e7cf8480b6e23ab MD5 | raw file
- ---
- warning: 'This file is auto generated by `npm run web:inject`, do not edit by hand'
- examples:
- - 'log(8723321.4, 7)'
- returns:
- - '8.212871815082147'
- dependencies: []
- authors:
- original by:
- - 'Onno Marsman (https://twitter.com/onnomarsman)'
- improved by:
- - 'Brett Zamir (https://brett-zamir.me)'
- notes: []
- type: function
- layout: function
- title: PHP's log in JavaScript
- description: >-
- Here’s what our current JavaScript equivalent to <a
- href="https://php.net/manual/en/function.log.php">PHP's log</a> looks like.
- function: log
- category: math
- language: php
- permalink: php/math/log/
- alias:
- - /functions/php/log/
- - /functions/math/log/
- - /php/log/
- - /functions/log/
- ---
- {% codeblock lang:javascript %}module.exports = function log (arg, base) {
- // discuss at: https://locutus.io/php/log/
- // original by: Onno Marsman (https://twitter.com/onnomarsman)
- // improved by: Brett Zamir (https://brett-zamir.me)
- // example 1: log(8723321.4, 7)
- // returns 1: 8.212871815082147
- return (typeof base === 'undefined')
- ? Math.log(arg)
- : Math.log(arg) / Math.log(base)
- }
- {% endcodeblock %}