Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Advanced one liner: Alle keys als array by value

    NEWS

    • Monatsrückblick – September 2025

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    • Neues Video über Aliase, virtuelle Geräte und Kategorien

    Advanced one liner: Alle keys als array by value

    This topic has been deleted. Only users with topic management privileges can see it.
    • Great SUN
      Great SUN last edited by

      Hi Ihr,
      es ist heute mal wieder zu spät bei mir... Naja, vielleicht hilft es ja dem ein oder anderen, wenn er die Lösung hat.
      Ich weiß, es gibt zu einer derartigen Funktion auch einen one-liner, aber ich komme einfach nicht drauf 😞

      Hier die Funtion:

      function getEqualValueKeyList(sourceValue) {
          var returnKeyList = [];
          for(const [key, value] of Object.entries(mySourceDict)) {
              if(value == sourceValue) {
                  returnKeyList.push(key);
              }
          }
          return returnKeyList;
      }
      

      Danke für Eure Hilfe!

      F 1 Reply Last reply Reply Quote 0
      • F
        fastfoot @Great SUN last edited by

        @great-sun ob ich das wirklich verwenden würde sei mal dahin gestellt
        Object.entries(mySourceDict).filter(r => r[1] === sourceValue).map(r => r[0])

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

        Support us

        ioBroker
        Community Adapters
        Donate

        1.2k
        Online

        32.2k
        Users

        80.8k
        Topics

        1.3m
        Posts

        2
        2
        163
        Loading More Posts
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as topic
        Log in to reply
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
        The ioBroker Community 2014-2023
        logo