javascript - Building Large Number from JSON -
at moment receive json objects. each object has 4 strings contain 3 digits. need construct large number digits. example if digits "111", "222", "333", , "444" number should 1112222333444. since need ===1112222333444 true, can't direct string concatenation because result wouldn't integer. fastest option transforming json number containing concatenated integers? want ignore first 5-6 digits if zeros.
you can concatenate them , convert them number
number("111" + "222" + "333" + "444") === 111222333444 // true or shorter
+("111" + "222" + "333" + "444") === 111222333444 // true this works if groups zero, because number or "+" interprets string number , doesn't parsing (opposite parseint, parse "010" 8, if no radix given, because interprets numbers leading zeros octal. there other differences)
Comments
Post a Comment