Search Results

Search found 3 results on 1 pages for 'kooiinc'.

Page 1/1 | 1 

  • Why does typeof NaN return 'number'?

    - by KooiInc
    Just out of curiosity. It doesn't seem very logical that typeof NaN is number. Just like NaN === NaN or NaN == NaN returning false, by the way. Is this one of the peculiarities of javascript, or would there be a reason for this?

    Read the article

  • Why can't I create a Date from a string including milliseconds?

    - by KooiInc
    In javascript you can create a Date object from a string, like var mydate = new Date('2008/05/10 12:08:20'); console.log(mydate); //=> Sat May 10 2008 12:08:20 GMT+0200 Now try this using milliseconds in the string var mydate = new Date('2008/05/10 12:08:20:551'); // or '2008/05/10 12:08:20.551' console.log(mydate); //=> NaN Just out of curiosity: why is this?

    Read the article

  • document.getElementById in toString

    - by KooiInc
    edit Found my answers here. Bottom line: toString/valueOf can only return primitive types. So here the lack of native getters in javascript shows, I suppose. I would like to use the following simple function in an elementwrapper: function ElGetter(id){ var id = id; return { set: function(nwid){id = nwid;}, toString: function(){return document.getElementById(id);}, valueOf: function(){return document.getElementById(id);} }; } var myEl = ElGetter('myId'); console.log(myEl.innerHTML); //=> undefined But I can't get it to work. Is it a DOM/javascript restriction or am I missing something? Normally it works, as in: function Tester(){ var x = 1; return { toString: function(){return x}, valueOf: function(){return x} } } var myTest = Tester(); console.log(myTest); //=> 1

    Read the article

1