通用函数:JavaScript还是PHP? [关闭]

While working on a recent project, I began wondering when somebody may use JavaScript vs. PHP for a generic function. Take this basic function (in JS) as an example, which simply returns whether or not a number falls within a particular range:

function range(num, var1, var2) {
    if ((num >= var1) && (num <= var2)) {
        return true;
    }

    else {
        return false;
    }
}

For something that doesn't query a database, nor is it information that should be — or needs to be — indexed for SEO (I know by default JavaScript will not be indexed), then my inference would be that JavaScript would be sufficient. But at the same time, PHP could be as well.

Basically, if the ONLY point of the application were a simple function like above (not that I can see a reason for that, but I digress...), then which langauge would be better to write this in? JavaScript or PHP?

Would love any insight as to which would be the best method to use and why. I recognize there is no right or wrong answer necessarily, but would like to hear arguments for or against one over the other.

Thanks!

As you point out, there is no necessarily right or wrong answer. I would say that it depends:

-Is it a problem for people to be able to reverse engineer the code?

-Is it a problem if it does not execute because JavaScript might be disabled?

-Is it preferable to have code execute client-side versus server-side from a performance point of view?

-Does the content generated by the output of this function qualify as something you might want indexed by Search Engines?

Depending on the importance of the above criteria/questions, JavaScript might be disqualified. From the points above, the common thing seems to be that choosing for JavaScript is more likely to lead to potentially undesirable side-effects.

The safest bet, from what I theorize, is therefore the server-side language, PHP.