✅ – Script – 13-00 Dec 1
is this a correct syntax
const [response] = await tasks.createTask()
Im familiar with the object destructuring method but this looks kinda weird11 Replies
yeah it's valid syntax
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
oh
but how does it work tho
I tried testing it by creating a function to return an array
["response", "jason"]
then I did
const ["jason"] = function();`
then console logged it and it kept on returning "response"The word that goes in the
[]
is the assigned variable name
And it's based on the position
horse
and tiger
can be whatever you want, it's the name of the variable you are declaringoh same way with useState
so it doesnt matter what i name the first and second index, the first would always be the state variable then the second would always be what changes the state variable
Yeah, because
useState
returns an array, the first element holding the current value and the second giving you the function that can update itUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
Which you are destructing
that makes sense
thanks
This question has an answer! Thank you for helping 😄
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/1047859831819739156
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/1047859831819739156
Question not getting answered? Maybe it's hard to answer, or maybe you asked at a slow time. Check out these resources for help asking a good question:
https://stackoverflow.com/help/how-to-ask
http://wp.me/p2oIwo-26