RoughJs 1.0-实现的JavaScript 2.0的编译器(1)
RoughJs
- 目录
Javascript简介(脚本,脚本语言的公共特性,)
数据类型
关键字
定义变量,Json,数组
全局对象,本地对象
表达示运算 一元运算,位运算,bool运算,+-*/ 关系运算
语句 if语句,迭代语句,break/continue,with语句,switch
函数
E4X for Xml操作
SVG操作
Javascript简介
根据Wiki的定义
JavaScript 是一种广泛用于客户端Web开发的脚本语言。由网景公司设计,是一种动态,弱类型,基于原型的语言,内置支持类。
当然我也觉得JavaScript不是一种简单的语言。
脚本语言的公共特性
同时支持批处理和交互式使用
经济的表达式
缺少声明,简单的作用域
灵活的动态类型化
易于访问其它程序
复杂的模式匹配和串操作功能
高级数据类型
数据类型
布尔,数字,字符,对象类型,undefined,null
关键字
break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof
定义变量
var <varname>[=<value>][,<varname>[=<value>]];
变量名可以使用字母,下划下,美元符号
定义字符型
var test1 ='test1',test2 ="test2";
alert(test1);
alert(test2);
定义数值型
var test3=4;
定义布尔型
var test4 =true;
定义Json
var test5 {
toLocaleString: "aaa"
};
定义数组
var test6=[1,2,"112232"];
定义Xml
var order = <order>
<customer>
<firstname>t1</firstname>
<lastname>t2</lastname>
</customer>
<item>
<description>Computer</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
</order>
var name = order.customer.firstname + " " + order.customer.lastname;
var total = order.item.price * order.item.quantity;
alert("The order XML object constructed using a literal is:\n" + order);
alert("The total price of " + name + "'s order is " + total);
浙公网安备 33010602011771号