1、js分为基本数据类型和引用数据类型
2、string定义为基本数据类型,但是既然为基本数据类型为什么还可以调用方法呢?
let a = "hello world"
a.name = "张三"
console.log(typeof a)
console.log(a)
3、string还有另外一种创建的方法 new String("hello world")
let b = new String("hello world")
b.name = "赵四"
console.log(typeof b)
console.log(b.substring(0, 2))
new出来的字符串则是对象类型,在我们打印的时候可以看到,调用方法的时候是通过原型进行调用方法的
4、在使用字符串方法的时候内部是就行new了的操作从而调用的方法。