Skip to content

Instantly share code, notes, and snippets.

@BideoWego
Created April 12, 2024 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BideoWego/483a218f9d8b6edd6a187397aea19e51 to your computer and use it in GitHub Desktop.
Save BideoWego/483a218f9d8b6edd6a187397aea19e51 to your computer and use it in GitHub Desktop.
Wanna FAFO what a jawn is? Use this javascript function!
/**
* Wanna FAFO what a jawn is? Use this function!
* @param {*} jawn The jawn. Any jawn.
* @returns {string} What the jawn is...
*/
function whatIsThisJawn(jawn) {
let answer = 'Yo this jawn is';
if (jawn === undefined || jawn === null) {
return `${answer} ${jawn}`;
}
return `${answer} an instance of ${jawn.constructor && jawn.constructor.name}`;
}
whatIsThisJawn(undefined);
//=> 'Yo this jawn is undefined'
whatIsThisJawn(null);
//=> 'Yo this jawn is null'
whatIsThisJawn(1);
//=> 'Yo this jawn is an instance of Number'
whatIsThisJawn('asdf');
//=> 'Yo this jawn is an instance of String'
whatIsThisJawn({});
//=> 'Yo this jawn is an instance of Object'
whatIsThisJawn([]);
//=> 'Yo this jawn is an instance of Array'
whatIsThisJawn(new Date());
//=> 'Yo this jawn is an instance of Date'
whatIsThisJawn(new Set());
//=> 'Yo this jawn is an instance of Set'
@BideoWego
Copy link
Author

When you're can javascript, but you're also a philly local.

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