Skip to content

Instantly share code, notes, and snippets.

@ShenTengTu
Created July 1, 2017 09:40
Show Gist options
  • Save ShenTengTu/97b666fd43185515f03fe841fda9f6dc to your computer and use it in GitHub Desktop.
Save ShenTengTu/97b666fd43185515f03fe841fda9f6dc to your computer and use it in GitHub Desktop.
Pure Object validation
/*isPureObject(item,strict)
- item(any) : the target to be checked.
- strict(boolean) : if 'true', just original Object can pass the check.
*/
function isPureObject(item, strict) {
if (item !== null) {
if (typeof item === 'object' && !Array.isArray(item)) {
if (strict) {
if (item.__proto__.__proto__ === null) {
return true;
} else {
return false;
}
} else {
return true;
}
} else {
return false;
}
} else {
return false;
}
}
@ShenTengTu
Copy link
Author

ShenTengTu commented Jul 1, 2017

see testing in JSFiddle :
https://jsfiddle.net/ShenTengTu/rghsnkct/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment