Script
Script2y ago

✅ – 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 weird
11 Replies
S3BAS
S3BAS2y ago
yeah it's valid syntax
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Script
Script2y ago
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"
S3BAS
S3BAS2y ago
The word that goes in the [] is the assigned variable name And it's based on the position
const [horse, tiger] = ["response", "jason"]
console.log(horse) // response
console.log(tiger) // jason
const [horse, tiger] = ["response", "jason"]
console.log(horse) // response
console.log(tiger) // jason
horse and tiger can be whatever you want, it's the name of the variable you are declaring
Script
Script2y ago
oh 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
S3BAS
S3BAS2y ago
Yeah, because useState returns an array, the first element holding the current value and the second giving you the function that can update it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
S3BAS
S3BAS2y ago
Which you are destructing
Script
Script2y ago
that makes sense thanks
reactibot
reactibot2y ago
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
reactibot
reactibot2y ago
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