Skip to content
This repository has been archived by the owner on Dec 30, 2019. It is now read-only.

Have we considered a paramater to the trimX() functions similar to C# usage. #22

Closed
JMcLauchlanSQ opened this issue May 11, 2018 · 2 comments

Comments

@JMcLauchlanSQ
Copy link

In C# you can very handily use .TrimStart("?"), this will remove specifically a "?" if it is at the beginning. This can be incredibly useful for very common cases where you want to remove starting string characters such as dealing with query urls on the web.
JS eg:

var query = ...;
if(query.indexOf("?") === -1)
    query = query.slice(1);

C# eg:
var query = (...).TrimStart("?");

Not sure if this has already been considered, just been using it a lot lately in C# and thought to check if it could be used in JS.

@ljharb
Copy link
Member

ljharb commented May 11, 2018

This proposal is cementing something that's already shipped in all browsers for years. It'd need to be a separate proposal. (you can also do .replace(/^?*/, ''))

@JMcLauchlanSQ
Copy link
Author

Ahhh, thanks for the quick response :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants