//该节没有怎么深入看懂,先留个坑
page 283:
//强大的数组推导(array comprehension)
function range(min, max) { for(let i = Math.ceil(min); i <= max; i++) yield i; } let evensquares = [x*x for (x in range(0,10)) if (x % 2 === 0)] // => [0,4,16,36,64,100] var data = [2,3,4,-5]; var squares = [x*x for each (x in data)]; var roots = [Math.sqrt(x) for each (x in data) if (x >= 0)] // => [1.41xxxxxxx, 1.732xxxxxxxx] var o = {a:1, b:2, f:function(){}}; Object.prototype.c = 3; let allkeys = [p for (p in o)]; // => ["a", "b", "f", "c"] let ownkeys = [p for (p in o) if (o.hasOwnProperty(p))] // => ["a", "b", "f"] let notfuns = [k for ([k,v] in Iterator(o)) if (typeof v !== "function")] // => ["a", "b"]page 285:
data.sort(function(a,b) b-a); let sumOfSquares = function(data) Array.reduce(Array.map(data,function(x) x*x), function(x,y) x+y); sumOfSquares(data) // => 计算平方和//插一句,关于function(x,y) x+y
page 286:
11.7 E4X: ECMAScript for XML
//它为处理XML文档定义了一系列强大的特性,属于服务器端技术
page 291:
//用Rhino需要用到java,电脑正好没配,配一下JDK
JAVA_HOME: D:\Haozi\Java\jdk1.6.0_14
CLASSPATH: .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
Path: %JAVA_HOME%\bin;
Rhino的解压位置:
D:\Haozi\progs\Rhino\rhino1_7R4
使用下面这行命令:
java -jar rhino1_7R4/js.jar program.js
其中program.js在1_7R4版本中貌似并没有发布抑或是我的调用方式有误
之后的几页讲的都是服务器端的javascript,没有看,又留了一个坑,等需要学习及应用时在快速掌握
page 314:
//CDATA
<script><![CDATA[ //这里是你的JavaScript代码 ]]></script>