時間
new Date('2018-01-01 01:01:01'); // 部分移動設備不能解析
new Date('2018/01/01 01:01:01'); // 正解
base64加密
window.btoa(unescape(encodeURIComponent('加密內容'))); // "5Yqg5a+G5YaF5a65"
decodeURIComponent(escape(window.atob('5Yqg5a+G5YaF5a65'))); // 解密
遍歷獲取對象鍵值
var xxx = {
'a': '1',
1: '2',
_: '3',
$: '4'
};
Object.keys(xxx).forEach(function (i) {
console.log(xxx[i]); // 2 1 3 4
});
for (i in xxx) {
console.log(xxx[i]); // 2 1 3 4
}
url編碼
var _url = encodeURI('url'); // 編碼
decodeURI(_url); // 解碼