Skip to content

Instantly share code, notes, and snippets.

@teamco
Created October 31, 2012 17:18
Show Gist options
  • Select an option

  • Save teamco/3988427 to your computer and use it in GitHub Desktop.

Select an option

Save teamco/3988427 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script data-main="scripts/core/application.js" src="scripts/lib/require.js"></script>
<script type="text/javascript">
// App.com.base.extendPrototype(App.Base, {
// clone: function clone(item) {
// if (!item) {
// return item;
// } // null, undefined values check
//
// var types = [ Number, String, Boolean ],
// result;
//
// // normalizing primitives if someone did new String('aaa'), or new Number('444');
// types.forEach(function (type) {
// if (item instanceof type) {
// result = type(item);
// }
// });
//
// if (typeof result == "undefined") {
// if (Object.prototype.toString.call(item) === "[object Array]") {
// result = [];
// item.forEach(function (child, index, array) {
// result[index] = clone(child);
// });
// } else if (typeof item == "object") {
// // testign that this is DOM
// if (item.nodeType && typeof item.cloneNode == "function") {
// result = item.cloneNode(true);
// } else if (!item.prototype) { // check that this is a literal
// // it is an object literal
// result = {};
// for (var i in item) {
// result[i] = clone(item[i]);
// }
// } else {
// // depending what you would like here,
// // just keep the reference, or create new object
// if (false && item.constructor) {
// // would not advice to do that, reason? Read below
// result = new item.constructor();
// } else {
// result = item;
// }
// }
// } else {
// result = item;
// }
// }
//
// return result;
// }
// });
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment