Skip to content

iterate object properties #606

@ghost

Description

I tried something that was not documented: "Iterate over an object"
code:

    <script type="text/hyperscript">
      init
        set $o to { name: "john", age: 30 }
        for value in $o index key
          log key
          log value
        end
      end
    </script>

But I could not get it working. Trying multiple methods, most of them resulted into an error.
console:

Uncaught TypeError: i.iterator is undefined
    op https://unpkg.com/hyperscript.org:1
    unifiedEval https://unpkg.com/hyperscript.org:1
    unifiedExec https://unpkg.com/hyperscript.org:1
    execute https://unpkg.com/hyperscript.org:1
    o https://unpkg.com/hyperscript.org:1
    setTimeout handler*install https://unpkg.com/hyperscript.org:1
    apply https://unpkg.com/hyperscript.org:1
    initElement https://unpkg.com/hyperscript.org:1
    processNode https://unpkg.com/hyperscript.org:1
    forEach https://unpkg.com/hyperscript.org:1
    processNode https://unpkg.com/hyperscript.org:1
    w https://unpkg.com/hyperscript.org:1
    n https://unpkg.com/hyperscript.org:1
    w https://unpkg.com/hyperscript.org:1
    promise callback*w https://unpkg.com/hyperscript.org:1
    <anonymous> https://unpkg.com/hyperscript.org:1
    <anonymous> https://unpkg.com/hyperscript.org:1

Since this works in normal javascript I think there must be a way to do this in hyperscript.
Please let me know how to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions