phpjs
Version:
69 lines (57 loc) • 1.86 kB
Markdown
layout: page
title: "JavaScript log10 function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/log10:465
- /functions/view/log10
- /functions/view/465
- /functions/log10:465
- /functions/465
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's log10
{% codeblock math/log10.js lang:js https://raw.github.com/kvz/phpjs/master/functions/math/log10.js raw on github %}
function log10 (arg) {
// From: http://phpjs.org/functions
// + original by: Philip Peterson
// + improved by: Onno Marsman
// + improved by: Tod Gentille
// + improved by: Brett Zamir (http://brett-zamir.me)
// * example 1: log10(10);
// * returns 1: 1
// * example 2: log10(1);
// * returns 2: 0
return Math.log(arg) / 2.302585092994046; // Math.LN10
}
{% endcodeblock %}
- [Raw function on GitHub](https://github.com/kvz/phpjs/blob/master/functions/math/log10.js)
Please note that php.js uses JavaScript objects as substitutes for PHP arrays, they are
the closest match to this hashtable-like data structure.
Please also note that php.js offers community built functions and goes by the
[McDonald's Theory](https://medium.com/what-i-learned-building/9216e1c9da7d). We'll put online
functions that are far from perfect, in the hopes to spark better contributions.
Do you have one? Then please just:
- [Edit on GitHub](https://github.com/kvz/phpjs/edit/master/functions/math/log10.js)
### Example 1
This code
{% codeblock lang:js example %}
log10(10);
{% endcodeblock %}
Should return
{% codeblock lang:js returns %}
1
{% endcodeblock %}
### Example 2
This code
{% codeblock lang:js example %}
log10(1);
{% endcodeblock %}
Should return
{% codeblock lang:js returns %}
0
{% endcodeblock %}
### Other PHP functions in the math extension
{% render_partial _includes/custom/math.html %}