微信小程序 基礎類庫

2022-04-27 14:51 更新

console

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

Math

屬性

  • E
  • LN10
  • LN2
  • LOG2E
  • LOG10E
  • PI
  • SQRT1_2
  • SQRT2
以上屬性的具體使用請參考 ES5 標準。

方法

  • abs
  • acos
  • asin
  • atan
  • atan2
  • ceil
  • cos
  • exp
  • floor
  • log
  • max
  • min
  • pow
  • random
  • round
  • sin
  • sqrt
  • tan
以上方法的具體使用請參考 ES5 標準。

JSON

方法

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

示例代碼:


console.log(undefined === JSON.stringify());
console.log(undefined === JSON.stringify(undefined));
console.log("null"===JSON.stringify(null));

console.log("111"===JSON.stringify(111));
console.log('"111"'===JSON.stringify("111"));
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(111===JSON.parse(JSON.stringify(111)));
console.log("111"===JSON.parse(JSON.stringify("111")));
console.log(true===JSON.parse(JSON.stringify(true)));

console.log(undefined===JSON.parse(JSON.stringify(function(){})));

Number

屬性

  • MAX_VALUE
  • MIN_VALUE
  • NEGATIVE_INFINITY
  • POSITIVE_INFINITY
以上屬性的具體使用請參考 ES5 標準。

Date

屬性

  • parse
  • UTC
  • now
以上屬性的具體使用請參考 ES5 標準。

Global

屬性

  • NaN
  • Infinity
  • undefined
以上屬性的具體使用請參考 ES5 標準。

方法

  • parseInt
  • parseFloat
  • isNaN
  • isFinite
  • decodeURI
  • decodeURIComponent
  • encodeURI
  • encodeURIComponent
以上方法的具體使用請參考 ES5 標準。


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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號