addyosmani / addyosmani/largescale-demo
Private variables vs instance properties
- Lenguaje dominante
- JavaScript
- Estrellas
- 137
- Forks
- 23
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Hi, this is more of a question than issue but can anyone explain why you might want to create errorNotice as a private variable in the first version of this module versus as a property on the instance in the second version? It seems in the first version you have to clean up the private variable whereas in the second version it will be removed when the instance is destroyed. Thanks!
```
// First version
app.core.define('#error', function(f){
var errorNotice;
return {
init: function(){
errorNotice = f.find('#alert')[0];
},
destroy: function(){
errorNotice = null;
}
}
});
// Second version
app.core.define('#error', function(f){
return {
init: function(){
this.errorNotice = f.find('#alert')[0];
},
destroy: function(){
// No longer need to null-out errorNotice
}
}
});
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Start by reviewing the two app.core.define('#error', ...) examples in the issue and the module lifecycle they illustrate. Done means providing a project-specific explanation of the trade-offs between the private variable and instance property approaches, including whether explicit cleanup is required.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- frontend
- Tipo de issue
- Documentación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 20/100