The difference between String and string in Typescript
TypeScript is a good advancement in the javascript ecosystem.
Today we are going to talk about the difference between the String and string types in Typescript.
Type error: Type 'String' is not assignable to type 'string'.
Let's take a look at the ...
josiasaurel.hashnode.dev2 min read
Here is an example that shows the differences:
var s1 = new String("Avoid newing things where possible"); var s2 = "A string, in TypeScript of type 'string'"; var s3: string;String is the JavaScript String type, which you could use to create new strings. Nobody does this as in JavaScript the literals are considered better, so s2 in the example above creates a new string without the use of the new keyword and without explicitly using the String object.
string is the TypeScript string type, which you can use to type variables, parameters and return values.