• tsonfeir@lemm.ee
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    1 year ago

    Holy hell no.

    The code you provided could be risky because:

    No Data Checking: It directly uses data from an API without checking if it’s safe or correct.

    Dynamic Properties: Adding properties to an object on the fly can make the code hard to manage.

    External Data Dependency: Relying on API data structure without checks can lead to issues if the API changes.

    If you don’t know the data is safe (it’s not), it’s a lot better to use an associative array. Additionally, if it’s from a json, it’s quicker and easier to iterate over array. Don’t make it complicated for no reason.