JSFiddle - React, Tailwind, and code Playground

JavaScript

var obj = {
    test: null,
    bar: {
        foo: function(){ return }
    }
};

var
    someRandom  = "other",
    otherRandom = "andother";

if (typeof obj[someRandom][otherRandom] === 'function'){
    console.log('function');
}