Answers for "string or string typescript"

0

string or string typescript

<script>
let a = new String("An object !");
let b = "A literal ! haha";
console.log(typeof(a));
console.log(typeof(b));
</script>

output is shown below.
object
string

In general, the string(with a small ‘s’) denotes a primitive whereas 
String(with an uppercase ‘S’) denotes an object

1.Primitive string: The string(with a small ‘s’) indicates a primitive,
primitives are values that hold no properties. 
2.String literals and a few strings returned from a string function
call can be classified as a primitive(string).
3. A primitive string can be converted to an
object by using a wrapper.
4. Object String: The object is an accumulation of different properties.
An object can call numerous methods corresponding to it.

Github: NathanNoSudo
Posted by: Guest on June-18-2021

Code answers related to "string or string typescript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language