Skip to content

Instantly share code, notes, and snippets.

@richistron
Last active December 23, 2015 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richistron/6708002 to your computer and use it in GitHub Desktop.
Save richistron/6708002 to your computer and use it in GitHub Desktop.
Respuesta a Cristian Camilo Chaparro
/*
No se si en en entendí to pregunta, pero me suena a estos posibles casos
*/
// Herencia de un objeto
// padre
var Parent = (function(){
// constructor
function Parent(){};
// propiedad true
Parent.prototype.item = true;
// regresa el objeto al decir "new Parent"
return Parent;
})();
// hijo
var Child = (function(super){
// extiende a super
Child.prototype = new super;
// constructor
function Child(){};
return Child;
})(Parent);
/*
A lo que yo creo que te refieres es a acceder al scope de otro clusure.
*/
// archivo 1
(function(){
var App = {};
App.propiedad1 = true;
window.App = App;
})()
// archivo 2
(function(){
var App = window.App || {};
App.propiedad2 = true;
console.log(App.propiedad1);
console.log(App.propiedad2);
window.App = App;
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment