JS看视频总结 数组----包括普通array数组和dictionary 和 new 匿名类
匿名类也很像是 js的arrayu 但是好像是没双引号的。因为毕竟dictionary是键值对,键说不定是要加引号的。
new 匿名对象
var expect = { TemplateExpectedInkUsage: templateExpectedText, TotalSuiteExpectedInkUsage: totalSuiteText, TotalRunsheetExpectedInkUsage: totalRunsheetText }
1.Array是动态的,无需定制大小,动态的(当做arraylist和dictionary用,数组是dictionary的特例)

arr[0]页面只能看到0,1,2,即输出的是对应的key
但是arr["人"],arr["口"],arr["手"]页面输出的是对应的值
所以:数组是dictionary的特例
数组的简化:

2.js中的类不是类而是对象
声明的时候像是C#的构造函数就可以了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript"> alert("hello"); function Person(name,age){ this.Name = name; this.Age = age; this.SayHello = function(){alert("My name is:"+this.Name+",I am"+this.Age+"years old!");} } var p1 = new Person("Tom",18); p1.SayHello(); </script> </head> <body> hello </body> </html>
3.js是动态的,弱类型的(“类”可以直接p.age=1;而不用在类声明的时候给出属性)
4.声明可以在调用之后
5.没有foreach只有for in这样代替foreach这样用

浙公网安备 33010602011771号