ekomS – 23-57 Dec 21
I have an object with nested functions, like so:
Is there any way I can specify default behavior if just
arrayFunctions
is called? Example: 6 Replies
@Smoke
arrayFunctions
is not a function, so you can't call it. You can make it a function and then attach properties to it
Is there any way to nest this assignment within the
arrayFunctions
function?
So that I don't need to write a new line for every deeply nested methodNo, because you first have to declare a function (which is a special kind of object in JavaScript) and then mutate it by adding properties
Though you could have a group of props, which you could define as a single object
I figured something out
This seems to work
I just give my desired default behavior the
_default
key
And then parse the object through turnObjectIntoFunction
before I export my function/object
Fobject?
There's probably plenty of ways to optimize but I'm quite possibly braindead after two hours of monkeying around with itI think you overcomplicated this, because it's easier to create an object and append it as function's prop than making some recursion stuff 😛
This thread hasn’t had any activity in 12 hours, so it’s now locked.
Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1055272921511243896