基本语法
/*
\d 0-9任意一个数字
[] 其中的任意一个字符
[0-9] \d
12 => [1][2] 12
[12a] 1、2、a
[a-zA-Z0-9]
[^] 非其中的任意一个字符
[^0-9]
\w 数字 字母 下划线
. 任意一个字符
[.] .
| 或
2|3 2、3
1[0-2]
1[012]
? 0-1次
0? [1-9]
+ 1-多次
* 0-多次
{,} 最少,最多
{6,12}
{6,}
{,12}
^ 开始
$ 结束
*/
// 字面量
var student={
id:10001,
name:"张三",
scores:[
{subject: "html",score: 90}
{subject: "JS",scros: 90 }
]
}
//function
function Student(id,name){
this.id=id;
this.name=name;
this.scores=[
{subject:"html",score:90},
{subject:"JS",score:90}
]
}
Student.prototype.sex="男";
Student.prototype.eat = function(food){
console.log("吃" + food)
}
var stu =new Student(1000,"张三");
stu.eat("米饭");
console.log(stu.sex)
// Object
var stu2=new Object();
stu2.id = 1000;
stu2.name ="张三";
stu2.scores=[
{subject:"html",score:90},
{subject:"JS",score:90}
]
function Student(id,name){
this.id=id;
this.name=name;
this.eat = function (food){
console.log("吃" + food)
return this
},
this.sleep = function(){
console.log("睡")
return this
}
}
// 链式编程
var stu = new Student(1001,"张三");
stu.eat("").sleep().eat("").sleep().eat("").sleep().eat("").sleep();
浙公网安备 33010602011771号