File tree 1 file changed +6
-2
lines changed
files/en-us/web/javascript/reference/global_objects/string 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -113,10 +113,14 @@ will automatically wrap the string primitive and call the method or perform the
113
113
lookup on the wrapper object instead.
114
114
115
115
``` js
116
- const strPrim = ' foo' ;
117
- const strObj = new String (strPrim);
116
+ const strPrim = " foo" ; // A literal is a string primitive
117
+ const strPrim2 = String (1 ); // Coerced into the string primitive "1"
118
+ const strPrim3 = String (true ); // Coerced into the string primitive "true"
119
+ const strObj = new String (strPrim); // String with new returns a string wrapper object.
118
120
119
121
console .log (typeof strPrim); // Logs "string"
122
+ console .log (typeof strPrim2); // Logs "string"
123
+ console .log (typeof strPrim3); // Logs "string"
120
124
console .log (typeof strObj); // Logs "object"
121
125
```
122
126
You can’t perform that action at this time.
0 commit comments