6.4: The Constructor Function in JavaScript – p5.js Tutorial




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”

  1. 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?

  2. 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

  3. 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 🙂

  4. 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!

Leave a Reply