DEV Community

Discussion on: Some Useful JavaScript String Methods You May Not Know About

Collapse
 
stephenmirving profile image
Stephen Irving • Edited

I also wanted to say that there really is no reason I can think of to ever use the String constructor new String('...') over a string primitive. The valueOf method is pretty much only for use internally by JavaScript, and is rarely if ever used in explicitly in production code. I don't think it is a good idea to have an example using the String constructor without also explaining why they most likely will never/should never use it.

Collapse
 
aumayeung profile image
John Au-Yeung

100 percent agree with that.

A string constructed with the constructor has type object which is confusing.

There is no benefit and its tricks people