You can create the literalObject and the genericFunction :
const literalObject = {
"value" : "string"
}
const genricFunction = function () {
console.log("value : ",this.value)
}
and then assign a property to the literalObject with bound genericFunction:
literalObject.genericFunction = genricFunction.bind(literalObject);
and whenever you call
literalObject.genricFunction();
it will use the literalObject as this
const literalObject = {
"value" : "string"
}
const genricFunction = function () {
document.write(JSON.stringify(this.value));
}
literalObject.genricFunction = genricFunction.bind(literalObject);
literalObject.genricFunction();