HISE Logo Forum
    • Categories
    • Register
    • Login

    detect "null"

    Scheduled Pinned Locked Moved Scripting
    23 Posts 5 Posters 1.2k 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.
    • Christoph HartC
      Christoph Hart @ulrik
      last edited by

      @ulrik I just skimmed through the JUCE codebase and the only time where null is used is when you convert a JSON object with a void field to a string (which would be the case if you do something like Console.print(trace(array) command). I guess that's just for compatibility reasons with the JSON standard and it is still being typed internally as void. I can't say why it is behaving like that with an inf number though, as this is clearly a number type and should be treated as such (eg. isDefined(1.0/0.0) returns true).

      However I got this output:

      3bc544cb-1827-4a81-8dc5-8be51f629e2b-image.png

      so apparently assigning void to a field is the same as assigning undefined (which I thought were two different things), however the isDefined() check works correctly on all of them.

      BTW, using inf as literal is not protected, so you can do stuff like:

      var inf = 90;
      Console.print(inf);
      
      ustkU 1 Reply Last reply Reply Quote 2
      • ustkU
        ustk @Christoph Hart
        last edited by ustk

        @Christoph-Hart Is it normal that a[2] set to null is throwing undefined ? It's weird to me because it is actually defined as null...

        EDIT: I think I have my answer...

        Just a moment...

        favicon

        (stackoverflow.com)

        console.log(null === undefined) // false (not the same type)
        console.log(null == undefined) // true (but the "same value")
        

        alt text

        Can't help pressing F5 in the forum...

        ulrikU 1 Reply Last reply Reply Quote 3
        • ulrikU
          ulrik @ustk
          last edited by

          @ustk 😂

          Hise Develop branch
          MacOs 15.3.1, Xcode 16.2
          http://musikboden.se

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

          32

          Online

          1.8k

          Users

          12.0k

          Topics

          104.5k

          Posts