Skip to content

Instantly share code, notes, and snippets.

View cheesits456's full-sized avatar
๐Ÿ’”
RIP Badger - May 26, 2020

Quin F. cheesits456

๐Ÿ’”
RIP Badger - May 26, 2020
View GitHub Profile
@cheesits456
cheesits456 / uneval.js
Last active October 7, 2025 14:41 — forked from cho45/uneval.js
Stringify multiple JS Object Types
function uneval(o) {
switch (typeof o) {
case "undefined": return "(void 0)";
case "boolean": return String(o);
case "number": return String(o);
case "string": return `"${o.replace(/\W/gi, function(_) { return `\\u${(0x10000 + _.charCodeAt(0)).toString(16).slice(1)}` })}"`;
case "function": return `(${o.toString()})`;
case "object":
if (o == null) return "null";
let ret, type = Object.prototype.toString.call(o).match(/\[object (.+)\]/);