Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #17559

Re: Cheap runtime asserts

From JJ <jaejunks@glegooilma-swapit.com>
Newsgroups comp.lang.javascript
Subject Re: Cheap runtime asserts
Date 2012-12-07 12:03 +0000
Organization A noiseless patient Spider
Message-ID <XnsA122C28BCCF7Fjaejunksglegooilma@0.0.0.23> (permalink)
References <1892433a-7696-4b03-a94c-0b1f0a984134@googlegroups.com> <XnsA121943364577jaejunksglegooilma@0.0.0.23> <cfb82688-a712-4e52-9ec3-ed7f0697320c@googlegroups.com>

Show all headers | View raw


glathoud <glathoud@yahoo.fr> wrote:
> Yes, you are right. The goal is not to catch 100% of the mistakes, but
> to have a good chance to catch strategic mistakes earls (see my answer
> to Patricia). 
> 
> In the case you are describing, you could instead make sure that the
> data property is defined IF that is what you need: 
> 
> node.childNodes[0].data.a;

Ah, I see what you're trying to do. Nice trick.

But how to do it if a parameter of null and non-null are both accepted by 
a function? For example, a function to toggle (set/clear) an element's 
onclick handler.

function toggleHandler(ele, func) {
  ele.onclick.a;
  func.a;
  ele.onclick = ele.onclick ? null : func;
}
function dummy() {}
//below line would cause an exception.
//it's expected since document doesn't have onclick property
toggleHandler(document, dummy);
//but below line would also cause an exception.
//assuming that document.body.onclick is null before call
toggleHandler(document.body, dummy);

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Cheap runtime asserts glathoud <glathoud@yahoo.fr> - 2012-12-04 22:00 -0800
  Re: Cheap runtime asserts Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-05 20:18 +0100
    Re: Cheap runtime asserts glathoud <glathoud@yahoo.fr> - 2012-12-06 11:19 -0800
      Re: Cheap runtime asserts Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-06 23:41 +0100
  Re: Cheap runtime asserts Patricia Shanahan <pats@acm.org> - 2012-12-05 12:00 -0800
    Re: Cheap runtime asserts glathoud <glathoud@yahoo.fr> - 2012-12-06 11:34 -0800
  Re: Cheap runtime asserts JJ <jaejunks@glegooilma-swapit.com> - 2012-12-06 07:29 +0000
    Re: Cheap runtime asserts glathoud <glathoud@yahoo.fr> - 2012-12-06 11:40 -0800
      Re: Cheap runtime asserts JJ <jaejunks@glegooilma-swapit.com> - 2012-12-07 12:03 +0000
        Re: Cheap runtime asserts glathoud <glathoud@yahoo.fr> - 2012-12-10 23:46 -0800
  Re: Cheap runtime asserts Stefan Weiss <krewecherl@gmail.com> - 2012-12-06 23:00 +0100
    Re: Cheap runtime asserts glathoud <glathoud@yahoo.fr> - 2012-12-11 00:07 -0800

csiph-web