This might seem very barbaric; I am trying to pass fApp and sApp and call them as objects and be seen as the jquery objects. So fApp will just fit into place here: $(ele).obj[fApp](to); and be seen as .insertAfter. They do not even need to be objects; I just want a way so I can pass values instead of writing 1000 appends, prepends and other stuff.
explained again
I know, I don't know how else to explain it. Pretty much just taking " fApp " and setting the value as " prependTo " and then call it here " $(ele).obj[fApp](to); " and have it act as though it is an actual prependTo
This whole function is just my mobile appender and desktop reappender. The value from is what grabs the parent element and than knows to append, prepend, after or before it when changed to desktop view.
function appendMaster(ele, to, fApp, sApp) {
var from = $(ele).parent();
console.log(fApp);
var obj = new Object;
var obj2 = new Object;
obj[fApp] = fApp;
obj2[sApp] = sApp;
var width = $(window).width();
if (width < 640) {
$(ele).obj[fApp](to);
};
if (width > 640 && width < 966) {
// Do something
};
if (width > 966) {
$(ele).obj2[sApp](from);
};
}
appendMaster("#forming","body", "prependTo", "prependTo");
$(ele)[fApp](to)- the terminology you're looking for is "computed property name"