asm.js使用示例代码
function mymodule(global, foreign, buffer) {
"use asm";// -------------------------------------------------------------------------
// SECTION 1: importsvar H32 = new global.Int32Array(buffer);
var HU32 = new global.Uint32Array(buffer);
var log = foreign.consoleDotLog;// -------------------------------------------------------------------------
// SECTION 2: functionsfunction f(x, y, z, w) {
// SECTION A: parameter type declarations
x = x|0; // int parameter
y = +y; // double parameter// SECTION B: function body
log(x|0); // call into FFI -- must force the sign
log(y); // call into FFI -- already know it's a double
x = (x+3)|0; // signed addition// SECTION C: unconditional return
return ((((x+1)|0)>>>0)/(x|0))>>>0; // compound expression
}function g() {
g_f = +g_i; // read/write globals
return;
}function g2() {
return;
}function h(i, x) {
i = i|0;
x = x|0;
H32[(i&0xffffffff)>>4] = x; // masked by 2^k-1, shifted by byte count
ftable_2[(x-2)&2](); // dynamic call of functions in table 2
}// -------------------------------------------------------------------------
// SECTION 3: function tablesvar ftable_1 = [f];
var ftable_2 = [g, g2]; // all of the same type// -------------------------------------------------------------------------
// SECTION 4: globalsvar g_i = 0; // int global
var g_f = 0.0; // double global// -------------------------------------------------------------------------
// SECTION 5: exportsreturn { f_export: f, goop: g };
}
javascript获取元素CSS样式代码示例
使用css控制页面有4种方式,分别为行内样式(内联样式)、内嵌式、链接式、导入式。行内样式(内联样式)即写在html标签中的style属性中,如divstyle="width:10
javascript列表框操作函数集合汇总
scriptlanguage="javascript"/*列表框互相操作函数集*///描述:添加不重复列表框元素functionselAdd(srcList,dstList){varselectedIndex=newArray();varcount=0;for(i=0;isrcList.options.leng
转换字符串为json对象的方法详解
JSON是一种便于操作使用的轻量级数据交换格式。易于人阅读和编写。同时也易于机器解析和生成。具体介绍请查看:http://www.json.org/。很多时候我们需