1、声明变量时,要标明变量的类型
如:let test:string = "nihao"
2、声明函数时,要标明返回数据的类型
3、引用类型有 Array、new String、date、正则表达式
4、字符串的方法有.length .indexOf() . lastIndexOf() .剪切.substring("2","3") 替换.repalce("你好","我好")
5、变量的作用域:局部变量 和全局变量。。元祖
6、什么是类,一种事物的集合,有属性和构造函数
7、通过new 一个类生成的实例叫对象
class XiaoJieJie{ //类
name:string;
age:number;
constructor (name:string,age:number){
this.name = name;
this.age = age;
};
say(){
console.log("你好这里是南方航空!")
}
}
let recall:XiaoJieJie = new XiaoJieJie("小红",20) //对象
console.log(recall)
recall.say()
8、修饰符:public(都可访问)、protested(本类和子类可访)、private (本类可访)
9、继承
class JsShuai extends Jspang{
public xingxiang:string = '帅气'
public zhuangQian(){
console.log('一天赚一个小目标')
}
}
let shuai = new JsShuai("技术帅",5,'演讲')
shuai.interst() //使用父类的方法
shuai.zhuangQian() //调用子类自身扩展的方法
10、重写,在子类重写父类的方法,方法名要一样
11、接口 interface Husband{ }
12、命名空间:
namespace shuaiGe{
export class Dehua{
public name:string = '刘德华'
talk(){
console.log('我是帅哥刘德华')
}
}
}
let dehua1:shuaiGe.Dehua = new shuaiGe.Dehua()
dehua1.talk()