JavaScript Split And the Limit Property

TimeOdd Stories - Javascript

One of the little used and known properties in JavaScript is the limit property in split. Limit returns the number of splits specified instead of all that can be found in a string. This is simpler than using regular expressions for simple operations like getting the first 2 lines of a string:

TimeOdd Stories - Javascript

Limit can also help with efficiency when parsing larger strings. For example, when parsing a file, it would be more efficient to extract the first 3 columns each time if a split with a limit of 3 was used:

TimeOdd Stories - Javascript

What do you think?

5 points

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Written by TimeOdd

TimeOdd is a leading technology media property, dedicated to obsessively profiling startups, reviewing new Internet products, and breaking tech news.



TimeOdd Stories - Snoring

Are you sick of snoring- find the secret

TimeOdd Stories - Tostada

Crunchy Tostada Ensalada – Fully Of Flavour