Re: [JSMentors] RE: Deferred script and onload event

2011-12-14 Thread Peter van der Zee
On Fri, Dec 9, 2011 at 1:53 AM, Geoffrey Knutzen geoffr...@seanet.com wrote: If a script is included on an html page with the deferred attribute, and the script attaches a handler to the window.onload event, and the onload event fires, will that handler ALWAYS be executed? Depends on actual

Re: [JSMentors] Object Declaration Question

2011-12-07 Thread Peter van der Zee
On Tue, Nov 22, 2011 at 8:32 PM, David Granado davidjgran...@gmail.com wrote: Any insight from the pros would be great. Arian is right. However, Firefox supports something called sharp variables. If you want to play around, that's basically what you want. I don't think it's very useful for ya

Re: [JSMentors] Onload event is not fired for dynamic script insertion

2011-12-07 Thread Peter van der Zee
Even though your script should run synchronous, it might not. The callback might have actually fired before your script got a chance to intercept it. I remember IE could prematurely fire the onload event for an image in primed cache if you set the .src before setting the .onload. Maybe the same is

Re: [JSMentors] how function is hooked to window.onload event

2011-10-27 Thread Peter van der Zee
On Thu, Oct 27, 2011 at 10:30 AM, Rahul rahulshivsha...@gmail.com wrote: hi, this is my code, function fngg(){   var f = function(){ alert(studentName); }   var studentName = Kate Adam Bikensale;   return f; } now i can call the above function using window's onload event as follows,

Re: [JSMentors] Subpatterns in regular expressions with the global modifier

2011-10-23 Thread Peter van der Zee
On Sun, Oct 23, 2011 at 10:41 AM, pete otaqui p...@otaqui.com wrote: Regular Expressions in Javascript don't make it easy to capture sub patterns when operating globally (i.e. using the 'g' modifier). snip... So are we stuck?  Do we need to use two separate string manipulation routines?  

Re: [JSMentors] Re: Default values for function arguments

2011-10-23 Thread Peter van der Zee
On Sun, Oct 23, 2011 at 4:46 PM, guipn gui.pinh...@gmail.com wrote: Passing undefined is something you don't have to do, for obvious reasons. It's not so much about explicitly passing it on. It can also happen to be the value of some variable, for whatever reason. var bar = giveMeAValue(); if

Re: [JSMentors] typeof vs other ways

2011-09-22 Thread Peter van der Zee
2011/9/22 Anders Jönsson joensson.and...@gmail.com: Hi On http://diveintohtml5.org/storage.html; they use the following code to check for local storage support: function supports_html5_storage() {     try {     return 'localStorage' in window window['localStorage'] !== null;     }

Re: [JSMentors] Essentials of interpretation Lesson 5. Simple user-defined functions.

2011-09-06 Thread Peter van der Zee
On Tue, Sep 6, 2011 at 12:46 PM, Pete Otaqui p...@otaqui.com wrote: Don't forget nothing (or an empty string): https://github.com/micmath/eMptyStringJS/blob/master/src/emptystring.js Although funny (and I actually did not know about it myself), it's not a valid identifier :) Just a valid

Re: [JSMentors] Reserved words

2011-08-27 Thread Peter van der Zee
On Sat, Aug 27, 2011 at 9:24 PM, Xavier MONTILLET xavierm02@gmail.com wrote: Does work in all implementations? And why do jslint and jshint cry? Just a bug? No. Most notably it doesn't work in older browsers. It used to be invalid syntax. That's why jslint and hint go nuts; if you use

Re: [JSMentors] this.abc in a function makes abc a property of window object, if function is called onLoad

2011-07-31 Thread Peter van der Zee
On Thu, Jul 28, 2011 at 6:04 PM, Xavier MONTILLET xavierm02@gmail.com wrote: You use this whereas you didn't call the function as a constructor with the new operator so it bind this to the global object aka window in browsers. Right. You usually use `this` in an object sense, where `this`

Re: [JSMentors] func.call vs. func.apply

2011-07-17 Thread Peter van der Zee
On Sun, Jul 17, 2011 at 2:26 AM, Matthew Bramer remym...@gmail.com wrote: So, I'm taking away from your answer that I should in general use .call I have to tell you, I have a hard time following what you have said though. I'm pretty new to this stuff, so some of your answer is clearly above my

Re: [JSMentors] func.call vs. func.apply

2011-07-17 Thread Peter van der Zee
On Sun, Jul 17, 2011 at 10:23 PM, Matthew Bramer remym...@gmail.com wrote: I think after reading everyone's thoughts on this topic, I probably could *get* the higher level stuff or at least have a great reference to look at. @Peter, Could you provide some use cases for .apply()? I really

Re: [JSMentors] new implementation

2011-07-15 Thread Peter van der Zee
On Fri, Jul 15, 2011 at 1:38 PM, Xavier MONTILLET xavierm02@gmail.com wrote: Hi, I think you should je return whaterver is returned by the constructor. Nah, construtors always return an object. If you don't (ie. `return 5;`), the original new instance is returned anyways. I would suggest

Re: [JSMentors] Re: JavaScript architecture

2011-07-14 Thread Peter van der Zee
On Thu, Jul 14, 2011 at 10:37 AM, David Marrs d.ma...@gmail.com wrote: I've tried JSLint and Closure, neither of which I liked.  I've overlooked JSHint, though.  It looks pretty good.  I'll definitely try it out when I start my next project.  If it works for me - which I hope it does because I

Re: [JSMentors] Feedback/code review for my canvas game

2011-06-12 Thread Peter van der Zee
On Sat, Jun 11, 2011 at 8:01 PM, Nick Morgan skilldr...@gmail.com wrote: I'd really appreciate any feedback/constructive criticism you guys have. Why did you go for the revealing/factory/functions created in constructor pattern rather than using prototype? - peter -- To view archived

Re: [JSMentors] Re: Stop loading image - LazyLoad

2011-06-10 Thread Peter van der Zee
On Fri, Jun 10, 2011 at 3:31 PM, Fyodorov quot;bgaquot; Alexander bga.em...@gmail.com wrote: btw you always can do {window.stop()} and restart loading again o_0 I didn't know this was exposed. Thanks! What's the support on it? - peter -- To view archived discussions from the original

Re: [JSMentors] HTML11

2011-06-02 Thread Peter van der Zee
On Thu, Jun 2, 2011 at 12:26 AM, Andrew Dodson andrew.j.dod...@gmail.com wrote: I was looking at http://www.html11.org/ And wondered if the religion element will expose a save() method with a callback handler. Didn't you know HTML is pretty much agnostic? Also, I'm rooting for a pinball tag

[JSMentors] Congratz on becoming a windows programmer

2011-06-02 Thread Peter van der Zee
Of course, slightly involuntarily. But it seems that we'll all be Windows 8 programmers! ( http://www.microsoft.com/presspass/features/2011/jun11/06-01corporatenews.aspx ) In all seriousness though, this could be interesting. And I believe this is a game changer, regardless of how you think of

Re: [JSMentors] JavaScript version vs. ECMAScript version

2011-05-24 Thread Peter van der Zee
On Tue, May 24, 2011 at 4:40 AM, Aaron Godin godin.aa...@gmail.com wrote: Hello JSMentors, My questions is slightly less technical than I have seen in here, but it is regarding versions of JS and ECMA script. Is there some way to know which Javascript versions each of the major browsers are

Re: [JSMentors] !function pattern

2011-05-12 Thread Peter van der Zee
Indeed, ! + - are all unary operators. The reason they are used is that a statement may not start with the function keyword because that's reserved for function declarations (which you can't immediately invoke because function declarations don't have a return value). So when you want to do the

Re: [JSMentors] is need to manually set some local var to 'null'?

2011-04-28 Thread Peter van der Zee
On Wed, Apr 27, 2011 at 11:03 PM, Allex allex_w...@163.com wrote: Hello, i want to consult some issues of javascript language, whether we need manually set some local variable (create by var xxx) to null? As usual, it depends. But for most cases you don't. At the end of a function, all

Re: [JSMentors] Just how efficient are JS function calls?

2011-04-14 Thread Peter van der Zee
On Thu, Apr 14, 2011 at 10:01 AM, Poetro poe...@gmail.com wrote: It just behaves totally differently from the embedded script tag. Adding it this way will load the file in an somewhat asynchronous way. And you also cannot have document.write statements in the JS files loaded this way, as the

Re: [JSMentors] The case for restrict mode

2011-03-28 Thread Peter van der Zee
On Mon, Mar 28, 2011 at 12:56 PM, Nick Morgan skilldr...@gmail.com wrote: On 28 March 2011 00:40, Olov Lassus olov.las...@gmail.com wrote: 2. + = = are restricted to primitive strings or numbers (but never a mix) I don't see how you're enforcing this. What about: function

Re: [JSMentors] accessing global variable in a callback

2011-03-21 Thread Peter van der Zee
On Sun, Mar 20, 2011 at 9:26 PM, tim perkis t...@perkis.com wrote: Is there something I'm not understanding about global scope? Maybe the fact that there is none :) Not in node in the classic sense anyways. I guess I would monkey patch your own object for debugging and just assign whatever

Re: [JSMentors] Edge cases with function declarations

2011-03-17 Thread Peter van der Zee
On Wed, Mar 16, 2011 at 4:05 PM, shaun shaun.ether...@gmail.com wrote: I think i read in the Google Javascript style guide that for situations like the one above, functions should be declared like: var f = function... I guess this is so var hoisting does the right thing for you? No. I

Re: [JSMentors] Pushing to Arrays

2011-03-16 Thread Peter van der Zee
On Thu, Mar 10, 2011 at 3:55 PM, Josi mich...@josi.de wrote: Can somebody explain this behaviour? http://jsperf.com/array-push Why it is better to use a function instead of direct access? It's not per se, although some browsers can optimize patterns they recognize. (If you somehow mess

Re: [JSMentors] Edge cases with function declarations

2011-03-16 Thread Peter van der Zee
On Mon, Mar 14, 2011 at 12:06 PM, Bruno Jouhier bjouh...@gmail.com wrote: Is this behavior precisely defined by the ECMAScript standard, or is it left open to interpretation? Enter Yuri or Dmitry ;) The simple answer is that yes, the ECMA standard specifically specifies that function

Re: [JSMentors] Array and for/in syntax

2011-03-16 Thread Peter van der Zee
On Fri, Mar 11, 2011 at 9:58 PM, Alex a...@scriptoid.com wrote: I'm struggling to find something very simple. Question 1: If I have an array of integers and I use a for-in construct, do I get them in the same order they are present inside array? No. In fact, for-in is not meant to iterate

Re: [JSMentors] Feedback request: JavaScript Engines: Under the Hood

2011-03-11 Thread Peter van der Zee
Fwiw, i liked the covered topics. But it seems a bit of a lonely world in that respect ;) On 11 Mar 2011 17:57, Ariya Hidayat ariya.hida...@gmail.com wrote: Folks, At the last SenchaCon 2010, I gave 10,000 foot overview talk on how JavaScript engine works. The recorded video is

Re: [JSMentors] Here Documents - has there ever been a standardization discussion?

2011-03-06 Thread Peter van der Zee
On Sun, Mar 6, 2011 at 7:39 PM, edvakf taka.atsu...@googlemail.com wrote: Hi, I'm wondering whether Here Document was ever discussed to be a standard JavaScript feature? If there was, could someone point me to the thread? I know that ES4 draft had triple-quote string literal, but was that

Re: [JSMentors] What are the alternatives to var self = this?

2011-03-05 Thread Peter van der Zee
On Sat, Mar 5, 2011 at 4:56 PM, אריה גלזר arieh.gla...@gmail.com wrote: I like $this personally - it is closest to original meaning, and has an additional bonus that some editors (such as vim) highlight it properly And I'd immediately think it would a jquery|framework object. We're not doing

Re: [JSMentors] Extensions on objects like c#

2011-03-05 Thread Peter van der Zee
On Sat, Mar 5, 2011 at 11:04 PM, Tom de Koning tomdekon...@gmail.comwrote: Hi all, I have been working with JS for quite a while, but coming from a .Net background. I was wondering if it is possible to do something like this in JavaScript: var expected = 5; var result =

Re: [JSMentors] What are the alternatives to var self = this?

2011-03-04 Thread Peter van der Zee
http://www.aminutewithbrendan.com/pages/20110303 On Fri, Mar 4, 2011 at 11:07 AM, Nick Morgan skilldr...@gmail.com wrote: On 3 March 2011 19:20, Michael Geary m...@mg.to wrote: Personally I like to use the same name for the object that I would typically use in code that *uses* the object.

[JSMentors] Re: IE script execution throttle

2011-02-20 Thread Peter van der Zee
Have the answer. Via Mathias (@mathias) through http://jsperf.com/faq#script-warnings http://support.microsoft.com/default.aspx?scid=kb;en-us;175500 Cheers. On 20 feb, 11:06, Peter van der Zee jsment...@qfox.nl wrote: Anyone know how to disable it locally? Would like to run some benchmarks

Re: [JSMentors] Global Object window is no longer this

2011-02-18 Thread Peter van der Zee
On Fri, Feb 18, 2011 at 4:00 AM, nathanJsweet nathanjsw...@gmail.comwrote: So in the new ECMA standard the body decided that when the this word is used at the highest hierarchical level (i.e. when it would normally That is only the case in so called strict mode. be the window object) would

Re: [JSMentors] Caching array length property

2011-02-18 Thread Peter van der Zee
On Fri, Feb 18, 2011 at 4:04 PM, Nick Morgan skilldr...@gmail.com wrote: Whenever I show anyone code like this though, they say you should cache the length property - you're looking it up on each iteration. So, what do you guys think? To me, the second option smacks of premature optimisation.

Re: [JSMentors] Re: Module pattern and testability

2011-02-17 Thread Peter van der Zee
On Thu, Feb 17, 2011 at 9:11 PM, Jason Mulligan jason.mulli...@avoidwork.com wrote: Why is that called a Module Pattern? It's just closure? No, that's the revealing pattern. It's the module pattern because all the variables, functions and constructors he defines are in a new own scope, which

Re: [JSMentors] Re: Module pattern and testability

2011-02-17 Thread Peter van der Zee
On Thu, Feb 17, 2011 at 9:32 PM, Jason Mulligan jason.mulli...@avoidwork.com wrote: That's hilarious ... do all javascript people just make up names for ops and call it patterns? Yes. We call it the imaginary pattern. - peter -- To view archived discussions from the original JSMentors

Re: [JSMentors] Passing by (copy of the) reference

2011-02-15 Thread Peter van der Zee
On Tue, Feb 15, 2011 at 10:17 AM, Ivan S ivan.sku...@gmail.com wrote: Let's say we have this example: (There's no need for the html cruft..) function testPassByRef() { var obj = {}; (function(passed_obj) { passed_obj = {prop : 'test'}

Re: [JSMentors] Nested Property Access

2011-02-15 Thread Peter van der Zee
On Tue, Feb 15, 2011 at 12:08 PM, Adrian Olaru agol...@gmail.com wrote: ((person2||{}).address||{}).zip || no zip); I find it harder to determine what's actually going on. But maybe it just takes a little time getting used to. Clearly not the way to go for apps where speed is important, but I

Re: [JSMentors] Nested Property Access

2011-02-15 Thread Peter van der Zee
On Tue, Feb 15, 2011 at 1:59 PM, Diego Perini diego.per...@gmail.comwrote: I believe this is almost equivalent: try { a = person2.address.zip; } catch(err) { a = 'no zip'; } Oh, actually I like that. Maybe even better unless you do it a lot. - peter -- To view archived discussions from

Re: [JSMentors] Nested Property Access

2011-02-15 Thread Peter van der Zee
On Tue, Feb 15, 2011 at 3:04 PM, Dmitry Pashkevich dip...@mail.ru wrote: I am not very savvy in using exceptions... Are there any pitfalls with their use in such case? There's a small performance hit (which may vary across engines). And possibly some odd collisions with the exception variable

Re: [JSMentors] JavaScript + dynamic CSS

2011-02-11 Thread Peter van der Zee
On Thu, Feb 10, 2011 at 11:55 PM, foldi foldifoldi.vi...@gmail.com wrote: I've joined a web development project with an enormous CSS file. One of my tasks is to develop another approach for styling the site that can dramatically reduce the total number of rules. I'm also creating a JS

Re: [JSMentors] JavaScript + dynamic CSS

2011-02-11 Thread Peter van der Zee
On Fri, Feb 11, 2011 at 1:57 PM, Trygve Lie p...@trygve-lie.com wrote: Hi Also, I think it's pretty much accepted to use dashes in CSS (rather than underscores or camel case). I would not use that. Dashes has a function in CSS. I'm sorry, but a dash is a horizontal bar, `-` and it has

Re: [JSMentors] Lua in browser as an alternative to JavaScript

2011-02-11 Thread Peter van der Zee
On Fri, Feb 11, 2011 at 3:24 PM, Adrian Olaru agol...@gmail.com wrote: I'm just wondering, why don't we have by now a Lua alternative to JavaScript in the browsers? The same could be said about python or any scripting language. A lua interpreter was converted to js through Emscripten (

Re: [JSMentors] Lua in browser as an alternative to JavaScript

2011-02-11 Thread Peter van der Zee
On Fri, Feb 11, 2011 at 4:07 PM, Chris Heilmann code...@gmail.com wrote: Yeah, I know how to sing pretty well. That doesn't make a good actor. Different languages have different goals. JavaScript was made to be interpreted in the browser - lightweight and fast. Other languages were meant to

Re: [JSMentors] Lua in browser as an alternative to JavaScript

2011-02-11 Thread Peter van der Zee
On Fri, Feb 11, 2011 at 7:40 PM, Jason Persampieri ja...@persampieri.netwrote: Bear in mind, I know nothing about compiler creation. How close are we to being able to polyfill in other language support? That is, parse and execute Lua (for one) code on the client side. Once we can do that

Re: [JSMentors] Re: JavaScript is the next C

2011-02-04 Thread Peter van der Zee
On Fri, Feb 4, 2011 at 8:40 PM, jemptymethod jemptymet...@gmail.com wrote: All well and good. But here's the thing. I don't *need* this group: my Javascript chops already get managers of frameworks like ExtJS and YUI interested in hiring me. Here's the thing. This list is about helping

Re: [JSMentors] Re: When we'll have a good IDE for JavaScript?

2011-01-28 Thread Peter van der Zee
On Fri, Jan 28, 2011 at 2:57 PM, Peter Higgins da...@dojotoolkit.orgwrote: On 1/28/11 8:50 AM, Max Vasiliev wrote: It looks like an advanced text editor, not an IDE. I.e. it doesn't have any debugging features, can't do any refactorings, doesn't have true autocomplete. Seems like a blurry

Re: [JSMentors] Re: JS API Design - Accepting Parameters

2011-01-20 Thread Peter van der Zee
On Thu, Jan 20, 2011 at 11:34 AM, Gregor gregor.kof...@gmail.com wrote: But this shifts the programmers task to remember the property names. /** * @param {Boolean} a * @param {String} b * @param {Object} options * - x:int=0 * - y:int=0 * - title:string= * - onClick:function=null * -

Re: [JSMentors] Multi thread JavaScript + multi core CPU = programming for the future

2011-01-17 Thread Peter van der Zee
On Mon, Jan 17, 2011 at 6:12 PM, Andraz andraz@gmail.com wrote: I want to develop multi core capable JS applications. Even if multi core support is not all around us today it will be soon enough in the good engines to think about it in advance. Hate to burst your bubble there, but there

Re: [JSMentors] Saving checkbox state in jquery.

2011-01-17 Thread Peter van der Zee
On Mon, Jan 17, 2011 at 7:37 PM, Garrett Smith dhtmlkitc...@gmail.comwrote: ... And for reasons I don't understand, you've top replied to the original post which appears below. Please stop doing that. Thanks. -- To view archived discussions from the original JSMentors Mailman list:

Re: [JSMentors] Re: Pattern for immediately invoked function - best use of parenthesis (function(){}()); or (function(){})();

2011-01-16 Thread Peter van der Zee
On Jan 15, 2011, at 5:27 PM, Michael Haufe (TNO) wrote: #1 - function(){ WScript.Echo(foo) }(); #2 - (function(){ WScript.Echo(foo) }()); #3 - (function(){ WScript.Echo(foo) })(); Can I just throw another variation in the mix? new function(){ WScript.Echo(foo); }; And now why this

Re: [JSMentors] Recommending this group

2011-01-16 Thread Peter van der Zee
On Sun, Jan 16, 2011 at 4:15 AM, Garrett Smith dhtmlkitc...@gmail.comwrote: Interactive discussion is a great way to learn. Good communication can go a long way towards facilitating clearer discussions http://www.faqs.org/rfcs/rfc1855.html (not listed on the group homepage, tsk). Is there a

Re: [JSMentors] jslint Move all 'var' declarations to the top of the function. is now a critical error

2011-01-15 Thread Peter van der Zee
On Sat, Jan 15, 2011 at 12:25 PM, And Clover and-...@doxdesk.com wrote: On Fri, 2011-01-14 at 10:12 -0800, cancel bubble wrote: I understand that it's good practice to declare all your vars at the top of your function I disagree. This is one part of Crockford Dogma I think is badly

Re: [JSMentors] setInterval overhead

2011-01-14 Thread Peter van der Zee
On Fri, Jan 14, 2011 at 6:28 AM, foldi foldifoldi.vi...@gmail.com wrote: I'm trying to understand something about setInterval. When running the following in FF3, the time it takes to execute the interval's function does not take longer than the 30ms specified for the interval. However, it

Re: [JSMentors] setInterval overhead

2011-01-14 Thread Peter van der Zee
On Fri, Jan 14, 2011 at 5:00 PM, Poetro poe...@gmail.com wrote: 2011/1/14 Peter van der Zee jsment...@qfox.nl: Certain browsers have a minimal interval at which timers can be called. For example, firefox has 10ms intervals. So timers simply can't be called faster than ten times per

Re: [JSMentors] jslint Move all 'var' declarations to the top of the function. is now a critical error

2011-01-14 Thread Peter van der Zee
Crockford updated his tool (jslint) recently (1). I'm not really happy with enforcing some of the options he has enforced, but that's how it is. If you don't like it, you can always fall back to http://jshint.com/ which is basically the same thing with different error output. It probably uses the

Re: [JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Peter van der Zee
On Thu, Jan 13, 2011 at 5:37 PM, Arlo arlo.carr...@gmail.com wrote: Example Method: A.) function drawPolygon( points, polyOptions ) { ... } B.) function drawPolygon( options ) { ... } I feel that with option B I can expand functionality a lot easier than with option A. Does anyone have

Re: [JSMentors] using new with Wrappers

2011-01-13 Thread Peter van der Zee
On Thu, Jan 13, 2011 at 5:50 PM, Amit Agarwal lifea...@gmail.com wrote: Hi, I tried using new with number primitive wrapper constructor. It gave a strange result. var numObj = new Number(2); *numObj = 2 {}* Any guesses what is this? The output doesn't really make sense (to me) in a js

Re: [JSMentors] using new with Wrappers

2011-01-13 Thread Peter van der Zee
On Thu, Jan 13, 2011 at 6:11 PM, Amit Agarwal lifea...@gmail.com wrote: I really didn't expect any output. It was doing fine until I used new. Without new it returns a number object. But when I tried to use new and logged it on the console, there I saw this output. Couldn't understand whether

Re: [JSMentors] using new with Wrappers

2011-01-13 Thread Peter van der Zee
On Thu, Jan 13, 2011 at 6:33 PM, Joel Dart jd...@dyknow.com wrote: Why? Well, simply because that's how the specification says it should be. I’m taking a guess here, trying to justify this and would appreciate feedback in my thinking. Since new has to set up the prototype chain, it

Re: [JSMentors] Re: Internet Explorer event handler leaks

2011-01-12 Thread Peter van der Zee
On Wed, Jan 12, 2011 at 3:25 AM, Balázs Galambosi galambal...@gmail.comwrote: 2011/1/12 Garrett Smith dhtmlkitc...@gmail.com: OK, I see that. I have IE9 running in IE8 document mode. I am using resource monitor and filtering for iexplore.exe. I am looking at the Memory live graph as I

Re: [JSMentors] Re: void function ?

2011-01-12 Thread Peter van der Zee
On Wed, Jan 12, 2011 at 7:07 AM, Nicholas C. Zakas jsmen...@nczonline.netwrote: ?To be more precise void is an operator, just typeof. The parentheses are optional, just like you can write -1 or -(1), the same is true for void(0) or void 0, although white space is required when parentheses

Re: [JSMentors] void function ?

2011-01-11 Thread Peter van der Zee
On Tue, Jan 11, 2011 at 8:35 AM, Adrian Olaru agol...@gmail.com wrote: or you just write undefined instead of void(0) or void 0. Minor fyi: While true, do note that in most cases, this incurs a (minor!) overhead for lookup (because undefined is actually a global variable) while void(0) is an

Re: [JSMentors] Creating new var in global scope; use `var` or not?

2011-01-08 Thread Peter van der Zee
On Sat, Jan 8, 2011 at 10:22 AM, Miller Medeiros lis...@millermedeiros.com wrote: On Fri, Jan 7, 2011 at 5:41 PM, Nick Morgan skilldr...@gmail.com wrote: to create a global variable. If I thought my code would be run outside of a browser then I'd create a global object as Dmitry P

Re: [JSMentors] Re: Internet Explorer event handler leaks

2011-01-07 Thread Peter van der Zee
On Fri, Jan 7, 2011 at 12:04 AM, Garrett Smith dhtmlkitc...@gmail.com wrote: When another code finds that object and adds an `_id` property, perhaps in a different version of a rendition of this approach, then what? Likely, if the object is window. Yes, I do believe I said it was an

Re: [JSMentors] Re: Internet Explorer event handler leaks

2011-01-07 Thread Peter van der Zee
On Fri, Jan 7, 2011 at 11:17 AM, Peter van der Zee qfo...@gmail.com wrote: ... I haven't encountered them personally (even though I've used the pattern quite a lot) Let me rephrase that; I've used a library (of my own) with that pattern quite a lot. It uses an expando to track DOM elements

Re: [JSMentors] Re: Internet Explorer event handler leaks

2011-01-06 Thread Peter van der Zee
Actually there was some discussion on twitter related to this. Jed drew a simple conclusion; expando's win in speed from alternative methods. http://twitter.com/jedschmidt/status/22784074045198338 The way I solved the leak pattern at some point was to use the expando pattern and store the

[JSMentors] Re: Internet Explorer event handler leaks

2011-01-06 Thread Peter van der Zee
On Jan 6, 10:28 pm, Bryan Forbes br...@reigndropsfall.net wrote: So, you would do something like this when attaching the initial event, right?: if(typeof elem._id == undefined){     elem._id = generateEventHandlerID(); } Indeed I didn't go into it in the article, but IE has a property

Re: [JSMentors] I don't get some of the fuss over node.js

2011-01-02 Thread Peter van der Zee
On Sun, Jan 2, 2011 at 10:27 AM, jemptymethod jemptymet...@gmail.comwrote: I don't get some of the fuss over node.js. Sure, it can be great to write most of your code, both client and server side in one language. But what's all the fuss over the event loop. Like they invented it or

Re: [JSMentors] Re: Improved Module Pattern?

2011-01-01 Thread Peter van der Zee
On Sun, Jan 2, 2011 at 12:17 AM, jemptymethod jemptymet...@gmail.comwrote: On Jan 1, 10:08 am, jmulligan jason.mulli...@avoidwork.com wrote: I do something similar with my lib (http://github.com/avoidwork/ abaaso) that's under dev. It works well, but you can't use private and public.

Re: [JSMentors] Re: IE firing onresize with dynamic content?

2010-12-31 Thread Peter van der Zee
On Fri, Dec 31, 2010 at 12:28 AM, cancel bubble cancelbub...@gmail.comwrote: It looks like I resolved this by writing my JavaScript properly (getting rid of that appending nonsense I had). I should have took the extra 5 minutes to do this properly before posting on the list (sorry!) If

Re: [JSMentors] Prototype

2010-12-29 Thread Peter van der Zee
can lead. See http://digitalize.ca/2010/12/prototype-vs-prototype-peter-van-der-zee-on-jsmentors/ (The source link in the bottom is a dead-end though) - peter -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com

Re: [JSMentors] Re: outsmarting the compiler?

2010-12-22 Thread Peter van der Zee
On Wed, Dec 22, 2010 at 7:46 AM, YANG Xudong wyver...@gmail.com wrote: On Tue, Dec 21, 2010 at 20:54, jemptymethod jemptymet...@gmail.com wrote: What is out-smarting the compiler, really? I often get criticized for the following style of for loop: for (var i=0, n=arr.length; in; i++)

Re: [JSMentors] Can I dynamically make a prototype link?

2010-12-20 Thread Peter van der Zee
On Mon, Dec 20, 2010 at 9:24 AM, Dmitry A. Soshnikov dmitry.soshni...@gmail.com wrote: On 20.12.2010 1:16, Lasse Reichstein wrote: On Sun, 19 Dec 2010 22:19:25 +0100, Juriy Zaytsev kan...@gmail.com wrote: On Sun, Dec 19, 2010 at 7:21 AM, Lasse Reichstein reichsteinatw...@gmail.com

Re: [JSMentors] Image polling through Javascript

2010-12-20 Thread Peter van der Zee
I need to send a fresh request for image every time my code sets the src. Any workarounds? Simplest solution is a so called cache buster which is a random string in the url. For most intentions and purposes, simply appending '?'+Math.random() to the end of the url will do the trick. (Note that

Re: [JSMentors] Can I dynamically make a prototype link?

2010-12-20 Thread Peter van der Zee
Really, I can't remember some _very_ needed use-case of exactly changing `__proto__` dynamically. First, yes, I'm analyze it from the theoretical design viewpoint. ECMAScript borrowed __proto__ from Python. It's called __class__ there -- and it's also mutable. Though, I also can't remember

Re: [JSMentors] Testing and the Revealing Module Pattern

2010-12-20 Thread Peter van der Zee
On Mon, Dec 20, 2010 at 3:43 PM, Peter Higgins da...@dojotoolkit.orgwrote: We have a build system we use for production code. In many of the places we have this same situation we use build pragmas to ensure the exposed reference is removed in production. eg: myns.module = (function(){

Re: [JSMentors] Testing and the Revealing Module Pattern

2010-12-20 Thread Peter van der Zee
(Hrm. I thought I had cut down the reply quote, sorry) -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To

Re: [JSMentors] Blog post: Namespacing in JavaScript

2010-12-16 Thread Peter van der Zee
The difference for me is that very first line tells me that I am creating a new Object. var counter = new function() { // must be an object ! //... } Where in contrast: var counter = function() { // `counter` is a function? // ... return { }; }(); // No, the function is called