HackDiary#012

8 comments

Write a comment

Log in or Register to join the conversation

superkaratemonkey

I prefer: value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value It's readable, easier to understand.

Daishi Kato
Creator

Thanks for your comment!

nehaldamania

I too prefet the 1st one as it is more readable. For regexp I normally would extract the regexp in a constant and name it to actually what it is doing. And naming is not easy too ;)

Daishi Kato
Creator

Thanks. To be precise, the first one actually needs to be this: ``` value.length > 1 && value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value ```

iamswain

I prefer second one. simple and learn REGEX!

Daishi Kato
Creator

Thanks. This is interesting. Some say one is easier to another, and some say the first one is faster. They are from various perspectives.

qodesmith

Regex is so complicated and difficult to parse. I'd prefer the first one for readability, but I do wish I had regex super powers!

Daishi Kato
Creator

Yeah, this one is simple but usually regex is hard to read.

HackDiary#128

HackDiary#127

HackDiary#126

HackDiary#125

HackDiary#124

See all posts from Daishi Kato

Powered by