支付寶小程序框架 SJS·基礎(chǔ)類庫

2020-09-18 10:28 更新

Global

注意:SJS 不支持 JavaScript 的大部分全局屬性和方法。

屬性

  • Infinity
  • NaN
  • undefined

具體使用請(qǐng)參考 ES5 標(biāo)準(zhǔn)。

方法

  • decodeURI
  • decodeURIComponent
  • encodeURI
  • encodeURIComponent
  • isNaN
  • isFinite
  • parseFloat
  • parseInt

具體使用請(qǐng)參考 ES5 標(biāo)準(zhǔn)。

console

console.log 方法可在 console 窗口輸出信息,可以接受多個(gè)參數(shù),將多個(gè)參數(shù)結(jié)果連接起來輸出。

Date

方法

  • now
  • parse
  • UTC

具體使用請(qǐng)參考 ES5 標(biāo)準(zhǔn)。

Number

屬性

  • MAX_VALUE
  • MIN_VALUE
  • NEGATIVE_INFINITY
  • POSITIVE_INFINITY

具體使用請(qǐng)參考 ES5 標(biāo)準(zhǔn)。

JSON

方法

  • stringify(object): 將 object 對(duì)象轉(zhuǎn)換為 JSON 字符串,并返回該字符串。
  • parse(string): 將 JSON 字符串轉(zhuǎn)化成對(duì)象,并返回該對(duì)象。

示例

console.log(undefined === JSON.stringify());
console.log(undefined === JSON.stringify(undefined));
console.log("null"===JSON.stringify(null));
console.log("222"===JSON.stringify(222));
console.log('"222"'===JSON.stringify("222"));
console.log("true"===JSON.stringify(true));
console.log(undefined===JSON.stringify(function(){}));
console.log(undefined===JSON.parse(JSON.stringify()));
console.log(undefined===JSON.parse(JSON.stringify(undefined)));
console.log(null===JSON.parse(JSON.stringify(null)));
console.log(222===JSON.parse(JSON.stringify(222)));
console.log("222"===JSON.parse(JSON.stringify("222")));
console.log(true===JSON.parse(JSON.stringify(true)));
console.log(undefined===JSON.parse(JSON.stringify(function(){})));

Math

屬性

  • E
  • LN10
  • LN2
  • LOG2E
  • LOG10E
  • PI
  • SQRT1_2
  • SQRT2

具體使用請(qǐng)參考 ES5 標(biāo)準(zhǔn)。

方法

  • abs
  • acos
  • asin
  • atan
  • atan2
  • ceil
  • cos
  • exp
  • floor
  • log
  • max
  • min
  • pow
  • random
  • round
  • sin
  • sqrt
  • tan

具體使用請(qǐng)參考 ES5 標(biāo)準(zhǔn)。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)