Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的激进表达:
var equation1 = "\\sqrt[4]{8}"; var equation2 = "\\sqrt[6]{x^2}";
如何使用javascript得到这个答案。
JavaScript 的求幂函数是Math.pow(base, exponent),所以 8 的 4 次方根是Math.pow(8, 1/4)。
Math.pow(base, exponent)
Math.pow(8, 1/4)
请参阅https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FMath%2Fpow等。
如果您要问如何解析您的这些字符串并进行评估,那完全是另一回事。