标签:属性 code 判断 component 汇总 cti script string return
if (typeof v === "undefined") { // ... }
function f() {} typeof f // "function"
var o = {}; var a = []; o instanceof Array // false a instanceof Array // true
var string = ‘Hello World!‘; btoa(string) // "SGVsbG8gV29ybGQh" atob(‘SGVsbG8gV29ybGQh‘) // "Hello World!"
function b64Encode(str) { return btoa(encodeURIComponent(str)); } function b64Decode(str) { return decodeURIComponent(atob(str)); } b64Encode(‘你好‘) // "JUU0JUJEJUEwJUU1JUE1JUJE" b64Decode(‘JUU0JUJEJUEwJUU1JUE1JUJE‘) // "你好"
var o = { key1: 1, key2: 2 }; Object.keys(o); // [‘key1‘, ‘key2‘]
var o = new Object(); o.hasOwnProperty(‘toString‘) // false ‘toString‘ in o // true
hasOwnProperty 判断对象本身 ,而 in 会判断对象父类
for (var key in person) { if (person.hasOwnProperty(key)) { console.log(key); } }
标签:属性 code 判断 component 汇总 cti script string return
原文地址:http://www.cnblogs.com/neverleave/p/6290282.html