That's a very good example of what I don't like about JavaScript especially when applied to the DOM.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm On Thu, 19 Mar 2015, at 05:12 PM, AndyHC wrote: > On 19/03/2015 20:12, Stephen Russell wrote: > > http://simpleprogrammer.com/2015/03/16/11-rules-all-programmers-should-live-by/ > > > > Interesting opinion on comments. They are Evil ??? > > > which pairs with "When writing code, we should strive to write code that > is clear and easy to understand". > > OK, well I'm trying for the third or fourth time to really get my head > around javascript - I pick up a 'grade II' book: example 1 reads fine; > example 2 I'm almost totally lost, even though I know exactly what it's > supposed to do - so it's back to js101 and '...the best bits' - again! > A few comments in the examples might have lifted me over the second > fence! > > fwiw here is my pons asinorum: > > (function() { > var results; > this.assert = function assert(value, desc) { > var li = document.createElement("li"); > li.className = value ? "pass" : "fail"; > li.appendChild(document.createTextNode(desc)); > results.appendChild(li); > if (!value) { > li.parentNode.parentNode.className = "fail"; > } > return li; > }; > this.test = function test(name, fn) { > results = document.getElementById("results"); > results = assert(true, name).appendChild( > document.createElement("ul")); > fn(); > }; > })(); > > > > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/1426860396.1695512.243016438.57808...@webmail.messagingengine.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

