Skip to content

Instantly share code, notes, and snippets.

@lilywang711
Last active December 13, 2019 07:07
Show Gist options
  • Save lilywang711/58ba75a274a4b4aaa5618df2af88e21c to your computer and use it in GitHub Desktop.
Save lilywang711/58ba75a274a4b4aaa5618df2af88e21c to your computer and use it in GitHub Desktop.
// 获取 url 的查询参数,转为 object
const decodeURI = (url = window.location.search) => {
return url.replace(/([^?&=]+)=([^&]+)/g,(_,k,v)=>q[k]=v)
}
// 1. 判断两个对象是否严格相等,保证isEqual(NaN, NaN)返回true。
// 2. 与Object.is 的区别在于对+0和-0的比较
function isEqual(a, b) {
return (a === b || (a !== a && b !== b));
}
// 为target对象添加methodName属性,并禁止该属性被修改或遍历
function addPropertyTo(target, methodName, value) {
Object.defineProperty(target, methodName, {
enumerable: false,
configurable: false,
writable: false,
value: value
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment