詞條
大約有 2,000 項符合查詢結(jié)果
,庫內(nèi)數(shù)據(jù)總量為 78,401 項。(搜索耗時:0.0046秒)
```javascript
// 舉例
function ourFunction(ourMin, ourMax) {
return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}
ourFunction(1, 9);
// Only change code below this line.
function randomRange(myMin, myMax) {
return Math.floor(Math.random()*(myMax-myMin+1))+myMin; // Change this line...
http://www.o2fo.com/chun5060/chun5060-8ow324c0.html
```javascript
// Setup
var testString = "Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it.";
// 舉例
var expressionToGetSoftware = /software/gi;
var softwareCount = testString.match(expressionToGetSoftware).length;
// Only change code below th...
http://www.o2fo.com/chun5060/chun5060-ia3s24c1.html
```javascript
// Setup
var testString = "There are 3 cats but 4 dogs.";
// Only change code below this line.
var expression = /\d+/g;// Change this line
// Only change code above this line
// This code counts the matches of expression in testString
var digitCount = testString.match(expression).lengt...
http://www.o2fo.com/chun5060/chun5060-gix324c2.html
```javascript
// Setup
var testString = "How many spaces are there in this sentence?";
// Only change code below this line.
var expression = /\s+/g;// Change this line
// Only change code above this line
// This code counts the matches of expression in testString
var spaceCount = testString.match(ex...
http://www.o2fo.com/chun5060/chun5060-9arg24c3.html
```javascript
// Setup
var testString = "How many non-space characters are there in this sentence?";
// Only change code below this line.
var expression = /\S/g;// Change this line
// Only change code above this line
// This code counts the matches of expression in testString
var nonSpaceCount = tes...
http://www.o2fo.com/chun5060/chun5060-7jtl24c4.html
在Javascript中,
var a = new A();它做了如下幾件事,
創(chuàng)建一個空的對象object
把object綁定到函數(shù)A的上下文中(即A中的this現(xiàn)在指向object)
執(zhí)行函數(shù)A
返回object
所以,var a1 = new A()與var a2 = A()這兩句有著本質(zhì)的區(qū)別!
http://www.o2fo.com/kesyi/kesyi-wyx524r9.html
JavaScript 支持情況
運行限制
基于安全考慮,小程序中不支持動態(tài)執(zhí)行 JS 代碼,即:
不支持使用 eval 執(zhí)行 JS 代碼
不支持使用 new Function 創(chuàng)建函數(shù)
客戶端 ES6 API 支持情況
微信小程序已經(jīng)支持了絕大部分的 ES6 API,已支持的 API 如...
http://www.o2fo.com/weixinapp/weixinapp-cad838s3.html
JavaScript 頁面類
* [I. 代碼實現(xiàn)](/secguide/secguide-yj8r3fky.html)
+ [1.1 原生DOM API的安全操作](/secguide/secguide-1wo53fkz.html)
+ [1.2 流行框架/庫的安全操作](/secguide/secguide-cm6t3fl0.html)
+ [1.3 頁面重定向](/secguide/secguide-nzas3fl5.html)
+ [1.4 JSON...
http://www.o2fo.com/secguide/secguide-owmy3fkx.html
...`link.href`、`area.href`、`input.formaction`、`button.formaction`;
```javascript
// bad: 跳轉(zhuǎn)至外部可控的不可信地址
const sTargetUrl = getURLParam("target");
location.replace(sTargetUrl);
// good: 白名單限定重定向地址
function validURL(sUrl) {
return !!((/^(https?:\/\/)?[...
http://www.o2fo.com/secguide/secguide-nzas3fl5.html
...llow](https://github.com/douglascrockford/JSON-js/blob/master/json2.js)
```javascript
// bad: 直接調(diào)用eval解析json
const sUserInput = getURLParam("json_val");
const jsonstr1 = `{"name":"a","company":"b","value":"${sUserInput}"}`;
const json1 = eval(`(${jsonstr1})`);
// good: 使用JSON.parse...
http://www.o2fo.com/secguide/secguide-iulh3fl6.html