Avatar for rwaldron

rwaldron

Member since Mar 2014 • Last active Apr 2014
  • 0 conversations
  • 7 comments

Most recent activity

  • in JavaScript
    Avatar for rwaldron

    I see, I misunderstood.

  • in JavaScript
    Avatar for rwaldron

    claps

  • in JavaScript
    Avatar for rwaldron

    Right, that won't work—Object.freeze only sets the meta object descriptor properties to: [[configurable]]: false, [[writable]]: false. It won't turn a non-object into a const. What you could do is provide a "built-in" keyword whose value is true and is essentially a const binding. Special keywords are safe additions, as long as they're not any of the FutureReservedWords: class, enum, extends, super, const, export, import, implements, let, private, public, interface, package, protected, static or yield; additionally, there is precedent in node with bindings like process, which aren't const, but are special (if you attempt to reassign it, the process itself will crash)

  • in JavaScript
    Avatar for rwaldron

    If the value is actually a floating point number, but you're receiving a string, then you should be able to simply coerce the value to a number and the non-numeric characters will be discarded:

    var ph = "8.55\r\n";
    
    +ph === 8.55; // true
    

    Unfortunately, that doesn't seem to work correctly in Espruino. I've filed a bug: https://github.com/espruino/Espruino/issues/268

  • in JavaScript
    Avatar for rwaldron

    There are several new syntax proposals for ES7 that would like to make use of "#", as it's one of the last ascii characters available. I strongly recommend avoiding the introduction of non-standard syntactic forms.

  • in JavaScript
    Avatar for rwaldron

    Regarding:

    for (var i in ["a","b","c"]) console.log(i)
    "a"
    "b"
    "c"
    

    This is incorrect. for-in will assign the value of the "key" (in this case the numeric index) to i, not the property "value".

    This is correct:

    for (var i in ["a","b","c"]) console.log(i)
    0
    1
    2
    
Actions