What is a constructor function in JavaScript? How does it work? How does it make objects? When should you use it? How can you duplicate objects into an array using the constructor function?
Next video:https://youtu.be/EyG_2AdHlzY?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
Support this channel on Patreon: https://patreon.com/codingtrain
Contact: https://twitter.com/shiffman
Send me your questions and coding challenges!: https://github.com/CodingTrain/Rainbow-Topics
Link to code on Github: https://github.com/CodingTrain/Rainbow-Code
p5.js: http://p5js.org
For More p5.js Videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
Help us caption & translate this video!
http://amara.org/v/Qbui/
Original source
27 responses to “6.4: The Constructor Function in JavaScript – p5.js Tutorial”
Love your videos! You are a fantastic teacher! Thank you for all you do!
This guy is just amazing!!! an Amazing developper!
he doesnt even use +=
So, can we say that " var vm = {};" and "vm.Summary = function( ) { } " Summary is a function constructor? what I want to do is to create within a object more reusable objects (contrsuctors), I am not sure if I am right, what do you think?
For some reason, brackets does not like the loop statement in setup, maybe I am doing something wrong but I have typed it in the exact same way as you.
"so you can see" Boum black screen XD
AWESOME TEACHER, AWESOME "COURSE". I watch it in 2x and you look too funny, like a crazy code wizard haha. Keep it up!
You are an amazing teacher. Your gestures and way teaching is very similar to one of my fav. teacher, Gaurang Sir, he is a physics teacher.
You should have mentioned the fact that when you go from an object syntax to a constructor syntax the ":" (colon) needs to be changed to an "=" sign and the "commas" ending all information in the object needs to be changed to a ";" semicolon
are you using brackets or p5 editor or processing
Awesome so good!!! I watched all the tutorials for p5.js since I am working on a game and every time I needed something you had the answer in the next video! Thanks so much. Very inspiring and keep up! 🙂
what happen if we call constructer function without new operator
omg! 3 minutos into the video and I already knew how good teacher you're. Subscribed and liked as well. Thanks for your explanations.
This helped me FINALLY understand constructor functions. I used to dread that word so much and fub my way thru but I GEDDIT NOW. I CANT THANK U ENOUGH DANIEL! ????
best, and funniest way to learn programming, I found until now!! 😀
done a few cpp and javascript crashcourses via "sololearn" apps..
but your videos are an amazing next step! help my mind growing with p5js/processing 🙂
Did you upload the code for this video somewhere?
when i use the "this.display":
this.display = function(){
rect(this.x,this.y,10,10)
};
nothing happens.
I am very confused, help.
When I create a function "move" in my object bubbles and then try to use it in draw it says move is not a function, any help?
Cool videos!! I have been learning a lot, Greetings from Colombia
stop cocaine ^^
Great Explaination. But when bubbles[i] = new Bubble() is replaced with bubbles[i] = Bubble(), the function comes undefined. Isn't it a basic assignment of function definition to a variable?
fiddle: https://jsfiddle.net/2dmgx1nr/2/
sorry Daniel Shiffman… but i must say… you teach damn good. love your videos!
the program that i used to write the code? what is its name? can anyone tell me more about it?
Thank you for this video! I understood the constructor's purpose but didn't fully understand a constructor and its use. I appreciate it! Sub'd!
Thanks for this vid!!
Great video! Thank you for making it. I found you by searching for techniques how to test Constructors using Jasmine. I haven't been able to find any posts/videos that effectively teach TDD dealing with DOM Manipulation or AJAX using Constructors. Anyone have a suggestion? Thanks!
Awesome video Daniel. Love the editing and examples!