JSFiddle - React, Tailwind, and code Playground

JavaScript

Object.prototype.safeGet = function(key) {
    return this? this[key] : false;
}
var nullObject = null;
console.log(Object.safeGet.call(nullObject, 'invalid'));