Quantcast
Channel: Posts/rss
Browsing latest articles
Browse All 38 View Live

Comment from holremasha

А как зовут ваших зверюшек? У меня кот Барс (балбес еще тот) Кошка Мусёна

View Article



Comment from rubudgirl

какие праздники вам нравятся?

View Article

Comment from DarrylHebbes

Thanks very much, been reading your posts since 2002...

View Article

Comment from Jonathan Snook

@DarrylHebbes: you hit it on the nose. You can access methods of other objects within that scope. It makes a handy shortcut and is exactly how I usually approach things.

View Article

Comment from DarrylHebbes

How would one go about setting the 'publicProperty' in the sub-module pattern from another method in the object. for example: MyObject = function(){ var util = { privateMethod: function(){...

View Article


Comment from Jonathan Snook

In the case of the calendar project, it was set up like this:calendar = function(){ var cal = { d:1, m:1, y:2006 } var monthView = { getEvents:function(){ var url = '/getevents?d= ' + cal.d + '&m='...

View Article

Comment from Rubiwachs

I was not looking for the code itself :), I am only interested in the structure of the code => 3 objects in the same namespace, accessing common values. Would you do it like this: if...

View Article

Comment from Jonathan Snook

@Rubiwachs: Unfortunately, it was for a client project, so I'm not allowed to publish what I did. The structure is much like that last example though where private objects are attached to a central...

View Article


Comment from Rubiwachs

Jonathan, could you elaborate more about your calendar example in 'code'? How do you mean: "The great thing about this was that each of the calendars could basically talk to each other while still...

View Article


Comment from Jonathan Snook

@Jack Turner: I like attaching it to the object as it's clear at the bottom of the function what I'm doing. If I have more than a couple functions then I have to scroll up to see where the object...

View Article

Comment from Jack Turner

Your code example can be made even clearer by returning the object containing the public properties and functions rather than storing it in the "obj" variable:MyObject = function(){ var privateMethod =...

View Article

Comment from Michael Jackson

@Jonathan: Excellent point. On a second read, I realize that my comment was a bit off topic, and I tend to agree with your points.

View Article

Comment from Jonathan Snook

@Michael Jackson: In the post, I tried to be specific in saying that private methods should be avoided. Private properties are less of an issue as properties hold state and not logic. Although, even...

View Article


Comment from Michael Jackson

One place where the Yahoo! guys use this technique is in the YAHOO.util.Anim class. There is a private variable called isAnimated. It's a variable that you just don't want users messing with. It only...

View Article

Comment from Andy Kant

@Jonathan Well, I've only used that in one particular case so far... I wrote an ActiveRecord-inspired extensible database system in JavaScript. It has a layering mechanism where any method (whether...

View Article


Comment from Jonathan Snook

@Andy: but who is the user and would they want to touch them anyway? It's interesting that you have a method in which to expose private variables if the user wants to. It does create a barrier that...

View Article

Comment from Andy Kant

I use private variables/methods pretty often to hide functionality that the user doesn't need to touch. However, for libraries that might be extended and need to access private variables, I provide an...

View Article


Comment from Peter Bex

Private variables are useful in one other situation: When you're extending existing functions to do something additional. Example: function somefunc() { ... }; (function() { var old = somefunc;...

View Article

Comment from alvin woon

hail object literals in JS. :) Beside using it in namespace containers, I find it also very handy for emulating static objects and other contructs. It is definitely one of the good stuff in JS and i...

View Article
Browsing latest articles
Browse All 38 View Live


Latest Images