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 a = 123456789 var b = 6
基于'b'我需要修剪'a'。例如,如果“a”有 8 位,我需要将“a”修剪到 6 位(123456)。如果 b 为 8,我需要修剪最多 8 位数字。请帮我
这听起来像做你想做的最简单的方法是:
a
b
这可能比尝试做你在算术上提出的要求更容易。
我假设你在javascript中?
var a = "123456789"; var b = 6; var n = a.substr(0,b);