module-pattern Questions

4

Solved

I'm reading the book Learning JavaScript Design Patterns recently. What I don't get is the difference between module pattern and revealing module pattern. I feel they are the same thing. Anyone can...

3

Solved

Edit for clarity - @Qantas94Heavy - I understand what it is "saying" or supposed to do, what I don't understand is why & more importantly how it works: I was reading an advanced tutorial on th...
Impalpable asked 24/8, 2013 at 17:3

5

Solved

I thought I was starting to understand JavaScript quite well but clearly not. Let me explain my problem with an example. First I have the following module defined: var Test = function() { var cou...
Dredge asked 9/2, 2013 at 22:15

2

Solved

I've created a module (following Javascript's Module Pattern) that makes an http request, caches and returns the result: var requestService = (function($) { var cache = {}; var get = function(...
Landfall asked 24/3, 2017 at 16:23

3

Solved

I've seen two different ways of implementing getters/setters in a module pattern. One uses "defineProperty", while the other doesn't. What are the advantages/disadvantages of one versus the other? ...
Ist asked 12/1, 2017 at 15:23

5

Solved

I am trying to understand the JavaScript Module Pattern. I've seen examples of what it should look like, but I don't understand how to use it. For example, a few things are happening here: $('inp...
Tester asked 20/8, 2012 at 17:31

2

Solved

I'm implementing the module pattern, and would like to know the best/preferred way to define and register event listeners/handlers. The following works, but maybe there is a better/simpler way... ...
Erinnerinna asked 11/11, 2011 at 20:48

4

Solved

I have the below code: filtersManager = (function ($) { var that = this; function configure() { // some work return that; }; function process() { // some work return that; } ret...
Riata asked 17/2, 2014 at 8:51

3

Solved

I'm trying to understand how public` properties in the (Revealing) Module Pattern work. An advantage pointed out by Carl Danley "The Revealing Module Pattern" is: Explicitly defined public metho...
Aalesund asked 30/5, 2015 at 11:13

2

Solved

I'm trying to get my head round the revealing module pattern in javascript. I'm puzzled by two things about the following code snippet. var Child = function () { var totalPoints = 100; addPoint...
Strega asked 17/1, 2012 at 10:33

3

Solved

Im new to javascript. Sorry if there is anything wrong with my question. How to inject/create/extend methods or plugins to our own library? here is "yourlib.js" var Yourlib = (function() { // pr...
Euromarket asked 28/5, 2013 at 8:0

6

Solved

I imitated a library and was able to write following code. This code created 'c' object to which 'a' function is assigned. So, to call 'a', I will have to write c.a(). Also, I was able to add more...
Spallation asked 15/1, 2015 at 9:48

2

How do I call a public function from within a private function in the JavaScript Module Pattern? For example, in the following code, var myModule = (function() { var private1 = function(){ // H...
Rangy asked 20/12, 2014 at 22:44

1

Solved

I just started learning patterns in JavaScript, and getting used to writing JavaScript like this: (function(window){ var privateVar; var privateFunc = function(param){ //do something } retu...
Ankerite asked 25/11, 2014 at 18:16

1

Solved

I'm trying to restructure some javascript and I'm confused about the module pattern. One way I have now is to simply declare a class containing all the functionality for a component like so var F...
Hankypanky asked 16/10, 2014 at 14:59

3

Solved

I would like to know if the module pattern or Constructor/protoType pattern is more applicable to my work. Basically I am using unobtrusive javascript -- the HTML document has a reference to the ....

1

I have just learned about the difference between Function Declarations and Function Expressions. This got me wondering about whether or not I'm doing things right in my AngularJS code. I'm fo...

3

Solved

Having trouble getting the following to pass jslint/jshint /*jshint strict: true */ var myModule = (function() { "use strict"; var privVar = true, pubVar = false; function privFn() { return...
Bauske asked 10/6, 2011 at 1:1

4

Solved

For the module pattern, I'm doing something like: (function(namespace) { // tons of code // blabla })(window.myGlobalNamespace); How do I split the code? I can think of a few ways, like use a ...

2

Solved

When implementing the module pattern, how do private functions access the private properties of the module? I haven't seen any examples where developers do this. Is there any reason not to? var mo...
Kola asked 20/12, 2011 at 18:5

5

Solved

After doing some reading about the Module Pattern, I've seen a few ways of returning the properties which you want to be public. One of the most common ways is to declare your public properties a...
Ariellearies asked 26/4, 2010 at 12:35

1

Solved

I have following pattern BASE = function () { var that = {}; var number = 10; that.showNumber = function(){ that.alertNumber(); } that.alertNumber = function () { alert(number); }; ret...
Bevatron asked 31/5, 2013 at 14:22

2

Solved

I'm trying to implement the inheritance with the module pattern in this way: Parent = function () { //constructor (function construct () { console.log("Parent"); })(); // public functions ...
Schoolbook asked 15/3, 2013 at 15:43

2

Solved

I have my JavaScript code split into few files, all using the module pattern (updating one global variable, say MyApp, with new features and members. Will it be possible to minify the files into o...
Caulis asked 21/2, 2013 at 8:29

3

Solved

I've seen the following three code blocks as examples of the JavaScript module pattern. What are the differences, and why would I choose one pattern over the other? Pattern 1 function Person(firs...
Rojas asked 10/12, 2012 at 18:56

© 2022 - 2024 — McMap. All rights reserved.