Re: [JSMentors] Re: Donations

2011-01-13 Thread Garrett Smith
On 1/9/11, Michael Haufe (TNO) wrote: > The jsmentors page mentions you are not employed atm. Have you > considered JS consulting and/or being a personal trainer for fitness? > Yes. -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@j

Re: [JSMentors] Re: "void" function ?

2011-01-13 Thread Marc Harter
IMO, any 'undefined' variable will do, as long as you know its in scope. void is kinda ugly to me, probably damage from all the 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 unsubsc

Re: [JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Nicholas C. Zakas
My general approach when designing APIs is to explicitly name required parameters and then have the last parameter be an options object. For instance, let’s say you’re designing an API to move an element to particular location. I’d design the API as: function moveTo(element, x, y, options){ }

[JSMentors] Re: JS API Design - Accepting Parameters

2011-01-13 Thread jdalton
I took a combo approach on a recent project: https://github.com/mathiasbynens/benchmark.js/blob/master/benchmark.js#L81 // I allow `fn` because test `fn` is required new Benchmark(fn); // or a name first because other devs require a name too (an options object for just a name is bulky) and... new

[JSMentors] Re: Detecting and reporting user defined global variables

2011-01-13 Thread jdalton
I remember @kangax made a bookmarklet to do this that uses an iframe's untouched global for comparisons. https://github.com/kangax/detect-global -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Goo

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

2011-01-13 Thread Garrett Smith
On 1/12/11, Peter van der Zee wrote: > On Wed, Jan 12, 2011 at 3:25 AM, Balázs Galambosi > wrote: > ]...\ > > > It kind of makes sense to fix that leak in compatmode. It doesn't affect the > display of the page directly but it would affect the browser, regardless of > compatmode. > Otoh, if they

Re: [JSMentors] Detecting and reporting user defined global variables

2011-01-13 Thread cancel bubble
Thanks for the prompt reply, will definitely check it out tomorrow am. -- 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@googlegrou

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

2011-01-13 Thread Garrett Smith
On 1/11/11, Balázs Galambosi wrote: > 2011/1/12 Garrett Smith : > >> 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 navigate between pages. I do not see any increase bet

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

2011-01-13 Thread Garrett Smith
On 1/13/11, Arlo wrote: > This group is the best thing that happen to the internet since > broadband! You guys are awesome! I definitely appreciate all > feedback and I am taking everything into consideration. What I really > need to apply from this discussion is type checking, jQuery came up

Re: [JSMentors] Detecting and reporting user defined global variables

2011-01-13 Thread Miller Medeiros
check how this guy is doing it: https://github.com/ruidlopes/scopeleaks he compares the ones that exists before and after the application executes... so you don't need to care about adding things manually. cheers. -- Miller Medeiros | blog.millermedeiros.com On Jan 13, 2011, at 8:45 PM, c

[JSMentors] Detecting and reporting user defined global variables

2011-01-13 Thread cancel bubble
Hello all, I'm attempting to build a little utility script I can include in all my dev projects/environment that will report any global variables. I can then investigate these globals and leave as-is ($ and jQuery for example) or hopefully correct them to not be globals. The goal is to reduce

[JSMentors] Re: JS API Design - Accepting Parameters

2011-01-13 Thread Arlo
This group is the best thing that happen to the internet since broadband! You guys are awesome! I definitely appreciate all feedback and I am taking everything into consideration. What I really need to apply from this discussion is type checking, so that param1 can be an object or a string depen

[JSMentors] Re: JS API Design - Accepting Parameters

2011-01-13 Thread Jorge
On Jan 13, 5:37 pm, Arlo wrote: > I am developing a JS API for my employer and I constantly ask myself > how I should accept params into my methods.  So I figured I would ask > the professionals. > > Here is my scenario: > 1.) I know a handful of basic methods that I need to implement right > now.

Re: [JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Anatoly Geyfman
On Thu, Jan 13, 2011 at 9:37 AM, Arlo wrote: > Here is my scenario: > 1.) I know a handful of basic methods that I need to implement right > now. > 2.) I do not know if functionality in these methods will expand in the > future > > Example Method: > A.) function drawPolygon( points, polyOptions )

Re: [JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Sergio Cinos
When creating an API, I always try to be as friendly as possible to the 'user' (the programmer using that API). So usually the best option is to support as many type of arguments (object, separate values...) as you can. Also, try to be permissive with the order. For example, if you build a join() f

Re: [JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Thomas Junghans
Hi Let's say you go for B), there's a good pattern you can use explained here: http://enterprisejquery.com/2010/08/javascript-parameter-patterns-with-extend-and-beyond/ I personally go for option B) when I cannot remember the order of the arguments or there simply are too many (> 3). Cheers tj

Re: [JSMentors] using new with Wrappers

2011-01-13 Thread Nick Morgan
On 13 January 2011 18:34, Peter van der Zee wrote: > On Thu, Jan 13, 2011 at 6:33 PM, Joel Dart 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.

Re: [JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Nick Morgan
On 13 January 2011 18:26, Poetro wrote: > Support both. > > I was going to say exactly the same thing. If you only need two arguments at the moment, use two arguments. If you need to expand later, make it so the function can optionally take a single options object. This doesn't have to break comp

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 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 > would neces

Re: [JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Poetro
Support both. If you are hesitant, you can support both ways. Take the jQuery API for example. It supports optional arguments, and depending on the type of the arguments they behave differently. -- Poetro -- To view archived discussions from the original JSMentors Mailman list: http://www.mai

Re: [JSMentors] Re: "void" function ?

2011-01-13 Thread Miller Medeiros
another approach is to create a function that checks if the param is undefined and store a reference to it on to the local scope for brevity.. in many cases it will be clearer (specially if you have multiple calls).. function isDef(param){ //return typeof param !== 'undefined'; //if you prefer n

RE: [JSMentors] using new with Wrappers

2011-01-13 Thread Joel Dart
>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 would necessarily have to return an object since primitives do not have proper

RE: [JSMentors] using new with Wrappers

2011-01-13 Thread Joel Dart
>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 its a >number or its an object. *Plug for JavaScript Patterns by Sto

Re: [JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Fran
What I do is: 1. If I'm quite sure there will be only 1: foo(arg) 2. If I'm quite sure there will be only 2: foo(arg1, arg2) 2. If I'm quite sure there will be more than 2: foo(/*Object*/args) 3. if I'm not sure how many of them there will be in the future: foo(/*Object*/args) 4. if I'm quite th

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 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 its a number o

Re: [JSMentors] using new with Wrappers

2011-01-13 Thread Amit Agarwal
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 its a number or its an object. -Regards *Amit Agarwal

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 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 context

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 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 advice or common pit

[JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Arlo
I am developing a JS API for my employer and I constantly ask myself how I should accept params into my methods. So I figured I would ask the professionals. Here is my scenario: 1.) I know a handful of basic methods that I need to implement right now. 2.) I do not know if functionality in these m

[JSMentors] Re: "void" function ?

2011-01-13 Thread Jorge
On Jan 12, 4:06 pm, Peter van der Zee wrote: > For a detailed concrete parse tree see: > > http://esparser.qfox.nl/#runnow:on,code:void-0 > > (hover mouse to see name of each node) Awesome! -- Jorge. -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-arch