[JSMentors] Re: JS Contests?

2011-10-30 Thread Michael Haufe (TNO)
On Oct 30, 3:00 am, Amit Agarwal lifea...@gmail.com wrote: These are general programming puzzles. I am looking for tricky JS questions which can't be answered without knowing internals of ECMAScript. Code Golfing may be something to look at as well then. @p01 is relatively notable in his

[JSMentors] Re: JS Contests?

2011-10-29 Thread Michael Haufe (TNO)
Are you simply looking for a prize to compete for, or some relatively simple ES puzzles to wrangle with? On Oct 29, 12:50 pm, Amit Agarwal lifea...@gmail.com wrote: Hi JS Folks, I was wondering if there is are programming contests for Javascript. Specially for the ECMAScript, the language

[JSMentors] Re: JS Contests?

2011-10-29 Thread Michael Haufe (TNO)
I used to play around with ProjectEuler: http://projecteuler.net/ Solutions are google-able in a variety of languages. You could also take a look at rosettacode.org and see if you can fill in some empty problems for JavaScript. Since other language solutions are listed you won't be completely

[JSMentors] Re: Function Parameter Checking

2011-10-29 Thread Michael Haufe (TNO)
On Oct 29, 2:41 pm, Jordan Harrison jorda...@gmail.com wrote: I'm not sure when and where it is best to check function parameters for the correct type and valid input. This question is almost always the source of a flame-war... What kind of function parameter type checking do you do? Do you

[JSMentors] Re: typeof vs other ways

2011-09-22 Thread Michael Haufe (TNO)
function supportsStorage(){ var ls = window.localStorage; return ls instanceof Object !isNaN(ls.length); } On Sep 22, 5:19 am, Anders Jönsson joensson.and...@gmail.com wrote: Hi On http://diveintohtml5.org/storage.html; they use the following code to check for local storage support:

[JSMentors] Re: Zakas Blog == Censored

2011-05-22 Thread Michael Haufe (TNO)
So a person is not allowed to review other people's code/library/book/ article? Only their own? On May 21, 3:09 am, Asen Bozhilov asen.bozhi...@gmail.com wrote: Via the JSMentors mailing list you can: Discuss ECMA-262 standard Discuss different implementations of ECMA-262 Discuss different

[JSMentors] Re: XML XSD Validation

2011-04-21 Thread Michael Haufe (TNO)
Its may be feasible to use XSL to validate. Since the XSD and the document are both XML format. There are a number of articles on the web describing the approach. Search for validate xml with xsl. It may be terser than a pure JS approach. On Apr 21, 7:47 am, Rocket yr.f...@gmail.com wrote: I'm

[JSMentors] Re: Why eval() is considered insecure?

2011-03-13 Thread Michael Haufe (TNO)
slow is a relative term. It's slower, yes since its not something that can generally be statically evaluated and compiled/JITed by the browser. less readable than the same code written with subscript notation. That really depends on how you are using both. evaled code is insecure. Maybe. If you

[JSMentors] Re: JavaScript. Array extras in detail.

2011-02-26 Thread Michael Haufe (TNO)
On Feb 23, 9:45 am, Dmitry A. Soshnikov dmitry.soshni...@gmail.com wrote: A new article written specially for Opera software: JavaScript. Array extras in detail. http://dev.opera.com/articles/view/javascript-array-extras-in-detail/ Related discussion on CLJS:

[JSMentors] Re: Nested Property Access

2011-02-19 Thread Michael Haufe (TNO)
by the community for good or ill. The drum I'm beating is that coding in a pattern ~vaguely~ similar to what you'd see in a statically typed language does not have to take away from the strengths of the language. Michael Haufe (TNO) wrote: Scott Sauyet wrote: [ ... ] When I program

[JSMentors] Re: Caching array length property

2011-02-18 Thread Michael Haufe (TNO)
On small arrays it is irrelevant, on larger ones where the length is greater than 5000 or so it can become noticeable. var a = []; a[10] = foo; var d1 = new Date(); for(var i=0; i a.length; i++); WScript.Echo(new Date() - d1 + ms); //34ms d1 = new Date(); for(var j=0, len = a.length; j

[JSMentors] Re: Nested Property Access

2011-02-17 Thread Michael Haufe (TNO)
On Feb 17, 8:04 am, Scott Sauyet scott.sau...@gmail.com wrote: Michael Haufe (TNO) wrote: As you or the OP or anyone else creates something beyond trivial code you mentally have some notion of types and contracts in your mind. But the contracts I consider when programming in Java are very

[JSMentors] Re: Nested Property Access

2011-02-16 Thread Michael Haufe (TNO)
On Feb 16, 7:40 am, Scott Sauyet scott.sau...@gmail.com wrote: There was a long interesting discussion of such functions on cljs last year.     http://groups.google.com/group/comp.lang.javascript/browse_thread/ thread/909ddea61f431a1a/ Too much noise-to-signal in that thread imo. -- To

[JSMentors] Re: The Node.Js is here and is growing, where's microsoft?

2011-02-15 Thread Michael Haufe (TNO)
were migrating to any other platform/technology. Johan On Tue, Feb 15, 2011 at 3:56 PM, Michael Haufe (TNO) t...@thenewobjective.com wrote: The bigger question is, beyond the hype what does node.js offer? Jumping from C# to JavaScript for example isn't exactly a step up. Same could

[JSMentors] Re: Nested Property Access

2011-02-15 Thread Michael Haufe (TNO)
Looks like a code smell of bad design. If you have a Person object it would be unnecessary to do member sniffing tests and literal injections like this. So instead of this: var person = {address: {zip: 1234}}, person2 = {}; console.log(Person2 undefined: +

[JSMentors] Re: Nested Property Access

2011-02-15 Thread Michael Haufe (TNO)
Person have a getZip() method to encapsulate the null checking? On Feb 15, 7:37 am, Michael Haufe (TNO) t...@thenewobjective.com wrote: Looks like a code smell of bad design. If you have a Person object it would be unnecessary to do member sniffing tests and literal injections like

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

2011-02-11 Thread Michael Haufe (TNO)
A language being static/dynamic isn't very relevant. Don't let crusty languages like Java ruin your impression of type systems. On Feb 11, 8:56 am, Adrian Olaru agol...@gmail.com wrote: I think an alternative is always a good idea. Java is big, is statically typed and it wasn't actually made

[JSMentors] Re: new Number(...) use case

2011-02-04 Thread Michael Haufe (TNO)
On Feb 4, 10:06 am, Angus Croll anguscr...@gmail.com wrote: [...] I've never yet had to use new Number() but there may yet be a scenario [...] If you want a consistent way to evaluate and enforce the type of individual values through the instanceof operator, this would be the approach to

[JSMentors] Re: Today, Web Development Sucks

2011-02-03 Thread Michael Haufe (TNO)
On Feb 3, 6:38 am, Chris Heilmann code...@gmail.com wrote: Well written, robust code that uses appropriate feature detection and fall back strategies is not difficult to write. That's why the web is full of that, right? If you write for yourself or an app for your hairdresser, yes. If you

[JSMentors] Re: The const keyword in JavaScript

2011-01-21 Thread Michael Haufe (TNO)
I've not read all of the ECMAScript specification document due to its nature so I am a bit puzzled; are const part of the ECMAScript standard or is it a Mozilla-specific extension as stated in the MDN doc? const is a reserved word according to ECMAScript 5 spec under 7.6.1.2 If the later, a

[JSMentors] Re: The const keyword in JavaScript

2011-01-21 Thread Michael Haufe (TNO)
I forgot to keep the attribution line for my last message. Trygve Lie p...@trygve-lie.com I'll just have to hope the Usenet nightstick stays in its glass case On Jan 21, 8:19 pm, Michael Haufe (TNO) t...@thenewobjective.com wrote: I've not read all of the ECMAScript specification document

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

2011-01-16 Thread Michael Haufe (TNO)
On Jan 16, 2:10 am, Peter van der Zee jsment...@qfox.nl wrote: Can I just throw another variation in the mix? new function(){ WScript.Echo(foo); }; [...] Actually don't know what jslint thinks of this, but as a prominent member of the community once said, jslint can suck it. jslint calls

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

2011-01-16 Thread Michael Haufe (TNO)
On Jan 16, 2:07 pm, Miller Medeiros lis...@millermedeiros.com wrote: [...] for me one of the biggest problems of JavaScript is that there is 1000 ways of doing the same thing... that's why IDEs can't do automatic error check or autocomplete properly and also the reason why books like

[JSMentors] IDEs

2011-01-16 Thread Michael Haufe (TNO)
On Jan 16, 7:45 pm, Miller Medeiros lis...@millermedeiros.com wrote: On Jan 16, 2011, at 6:44 PM, Michael Haufe (TNO) wrote: On Jan 16, 3:17 pm, Miller Medeiros lis...@millermedeiros.com wrote: The same way that is way easier to create a XML parser than an HTML parser. No, this analogy

[JSMentors] Re: using new with Wrappers

2011-01-15 Thread Michael Haufe (TNO)
On Jan 14, 9:15 pm, Joel Dart jd...@dyknow.com wrote: Creating Number objects is pretty much useless. If you ever need an *object* that stores a number value, you can just create a custom object yourself and store the number value as a property - it's probably also better Object Oriented

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

2011-01-15 Thread Michael Haufe (TNO)
#1 - function(){ WScript.Echo(foo) }(); #2 - (function(){ WScript.Echo(foo) }()); #3 - (function(){ WScript.Echo(foo) })(); #1 is an error. #2 and #3 both work. If I type foo or if I type (foo) they are semantically the same thing. same as if I type 1 vs (1), etc. The fact that function(){}()

[JSMentors] Re: Improved Module Pattern?

2011-01-02 Thread Michael Haufe (TNO)
On Jan 2, 1:33 am, jemptymethod jemptymet...@gmail.com wrote: On Jan 1, 6:56 pm, RobG rg...@iinet.net.au wrote: The use of $ may be Ok in ECMA-5, but it still grates with me. If you want to be able to safely access private variables and objects, you need privileged functions that are

[JSMentors] Re: What year was JSON invented?

2011-01-02 Thread Michael Haufe (TNO)
From http://yuiblog.com/yuitheater/crockford-json.m4v the first few seconds he mentions a Netscape employee using the idea in 1996. On Jan 2, 7:47 am, Michael Haufe (TNO) t...@thenewobjective.com wrote: I'm assuming you need some form of written proof vs. claims of JS developers using it before

[JSMentors] Re: Improved Module Pattern?

2011-01-01 Thread Michael Haufe (TNO)
...@gmail.com wrote: On Jan 1, 8:48 pm, Michael Haufe (TNO) t...@thenewobjective.com wrote: Unless private variables contain some type of uber-secret personally damning info, why not just use this? Consider familiarizing yourself with the module pattern, seehttp://www.yuiblog.com/blog/2007

[JSMentors] Re: Prototype

2010-12-29 Thread Michael Haufe (TNO)
On Dec 29, 1:25 am, Emeka emekami...@gmail.com wrote: [...] Is Prototype JavaScript's way of solving Expression Problem? [...] The short answer is that Brendan Eich probably wasn't thinking about it when he built the language in the 9 days he had available. The longer answer is that yes it is

[JSMentors] Re: Still confused with prototypal OO

2010-12-24 Thread Michael Haufe (TNO)
On Dec 24, 3:05 pm, Garrett Smith dhtmlkitc...@gmail.com wrote: I rather have it one way or the other. e.g.   makePoint(x, y);  - OR -   new Point(x, y); I just don't like seeing any extra if/else in the code. I also don't want to handle the case where somebody might be relying on an

[JSMentors] Re: Still confused with prototypal OO

2010-12-23 Thread Michael Haufe (TNO)
On 23.12.2010 18:28, Joel Dart wrote: new is a bad part primarily because of its dangerous potential for adding global variables. Specifically, using the previous example function A(x) {   this.x = x; } A.prototype.foo = function () {   return this.x; }; // and instance of

[JSMentors] Re: outsmarting the compiler?

2010-12-19 Thread Michael Haufe (TNO)
More accurately, the more type stable the code is, the easier it is for the engine. In other words, don't reuse a variable that used to hold a number and assign it an object, then a string, then a function, etc On Dec 19, 3:48 am, Szymon Piłkowski szymon.pilkow...@gmail.com wrote: Hello,