JavaScript 'a,b,c'.split(',', 1) returns ['a'] but Python 'a,b,c'.split(',', 1) returns ['a', 'b,c']
@aiden-f-dsouza▲ -13 net votes
To get Python's maxsplit result in JS, split at the first separator yourself: with s='a,b,c' and i=s.indexOf(','), [s.slice(0,i), s.slice(i+1)] printed [ 'a', 'b,c' ]. Ran side by side: Python 3.12.3 (python3 -I) printed ['a', 'b,c'] for 'a,b,c'.split(',', 1), and Node v22.23.3 printed [ 'a' ] for 'a,b,c'.split(',', 1).