0

If i pass an empty variable through an object constructor, will that previously empty variable now be a function?

Heres an example: var myFunc; function func(1,2,3,4) { this.1 = "bla bla bla"} then i write the func callback draw() { var a - new func(muFunc); Does doing this make the var [myFunc] a new constructor func for this instance?

3rd Jun 2022, 12:57 AM
pHANTOM|sTEELE
4 Antworten
+ 2
Thanks! I've been learning "the big 3" for years. I've got html & css down but JS is tough. I know I'm making progress though because I'm starting to get how "it" all goes together. My biggest issue is I'm a messy coder... I look at my unfinished code like "what... The... #&@$!!”
3rd Jun 2022, 4:32 AM
pHANTOM|sTEELE
+ 1
function func( 1, 2, 3, 4 ) looks more of an invocation rather than a definition. There should be parameter names, not arguments. "Does doing this make var <myFunc> a new constructor for this instance?" Why would it be? I'm not aware of ways to add a constructor to a class at runtime until now. (Edit) So I've noticed you posted several questions around what seems to be a similar case (your game code). I think you might be able to improve your chances for good answers if you can rephrase your question (and Description) for viewers' better comprehension of the actual problem.
3rd Jun 2022, 1:43 AM
Ipang
+ 1
I feel like I'm understanding a lot more about JS. But I'm still at the point where I start with a good idea then wade through chest deep console errors until I lose the logical vision I had for the project and scrap it. even now I have yet to finish something that I can be proud of. I'm close today though! My main issue is when I get stuck trying to do something and Google doesn't usually help but for quick reference, I don't know anyone that can explain to me why I'm having an issue and how to prepare myself against bad habits. Well anyway. This is (I think) the code from earlier with it's improvements(Dom is a lil messed) Let me know what you think: https://code.sololearn.com/WPDKxX7unVEe/?ref=app
3rd Jun 2022, 3:53 AM
pHANTOM|sTEELE
0
Unfortunately, I'm not that go to guy when it comes to canvas animation. So I guess I'll just leave it for those who are good at it. Don't worry too much about not making something to be proud of. I haven't any myself either. Just be happy with your progress in learning, and keep the small but continuous paces 👍
3rd Jun 2022, 4:08 AM
Ipang