$(function () {
let check = function() {
    setTimeout(function () {
        if (cLANGUAGE == null)
            check();
    }, 500);
};
if (cLANGUAGE == null) check();
alert(cLANGUAGE);
$('#details--action-share').on('click', function () {
    Action.details.share.before();
});
});
When I write like this, it still alerts cLanguage is null. I want to wait until cLanguage is not null then run below code
$('#details--action-share').on('click', function () {
    Action.details.share.before();
});). 
How can I do this?
 
     
     
    