Profile PictureDaishi Kato

HackDiary#012

8 comments

Current user avatar
Log in or Register to join the conversation

Comment author avatar
superkaratemonkey

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

Comment author avatar
Daishi KatoCreator

Thanks for your comment!

Comment author avatar
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 ;)

Comment author avatar
Daishi KatoCreator

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

Comment author avatar
iamswain

I prefer second one. simple and learn REGEX!

Comment author avatar
Daishi KatoCreator

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

Comment author avatar
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!

Comment author avatar
Daishi KatoCreator

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

HackDiary#093

HackDiary#092

HackDiary#091

HackDiary#090

HackDiary#089

See all posts from Daishi Kato