HISE Logo Forum
    • Categories
    • Register
    • Login

    Inconsistent typeof

    Scheduled Pinned Locked Moved Bug Reports
    2 Posts 2 Posters 196 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • d.healeyD
      d.healey
      last edited by

      I would expect the console output of this code to be number : number. But for some reason if I don't initialize the array element it increments it and turns it into a string.

      const var foo = [];
      const var bar = [0];
      
      foo[0]++;
      bar[0]++;
      
      Console.print(typeof foo[0] + " : " + typeof bar[0]);
      

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        If you google "Javascript weirdness", that's just the tip of the iceberg...

        1 Reply Last reply Reply Quote 1
        • First post
          Last post

        30

        Online

        1.7k

        Users

        11.9k

        Topics

        103.6k

        Posts