Rory's Blog
Home
Blog
Projects
Facebook
Google+
Github
RSS

Javascript: Prototype No Understand

01/30/15

So, yesterday, I tried to implement the state pattern in javascript, and at first I tried to have the object modify itself, and so I was trying to mess around with javascript prototypes.

It was at this point I realized I have no idea how javascript prototypes work or how to actually implement their use. I've read about them plenty, and remember seeing examples, but right now I can't imitate any of those examples because I don't really remember the exact wording or purpose of the examples.

So, I implemented a pseudo-state setup with a state variable that changes to a value representing what state it is in, and functions that act differently based on that state. This will be what I use for my timer initially. Thinking about it gives me some ideas on how to do things without prototypes and messing with the internal object that much.

In any case, some exploration of prototypes will be in order, once I implement some more functionality with my timer with what I can do right now with states and stuff.

Can't get too distracted learning new things without doing anything, and can't get too far into a depth-search on how to do something exactly how I want it without making compromises first and getting something functional quickly.