JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.debug.js"></script>
JavaScript
var isObservable = function (item) {
return (item && item.G);
};
var entity = {
name: 'I am whatever generic object'
};
// Assigning value to the target object
var target;
// target can be of any of thr following types
target = ko.observableArray(); // knockout observable array (function)
// target = ko.observable(); // knockout observable (function)
// target = {}; // generic object
// target = []; // generic array
//#region resolve method to call
var method;
if (isObservable(target)) {
method = target.push || target;
} else {
method = target.push || function (item) { target = item; };
}
//#endregion
// call resolved method
method(entity);
console.dir(target);