Practical JavaScript (objects)

I just put in about an hour into the Objects module of the Practical Javascript by Gordon Zhou. His teaching style is unlike others. Instead of going over concepts blindly, he puts us under the keyboard and teaches us while we code. He gives us the examples and then uses it to back up his teachings.

Now, everyone is different but this particular teaching style fits well with me. I was able to better understand this keyword in javascript in ways I couldn’t before. Part of this blog is to document my learnings and internalize different concepts I had trouble in the past. Hang on tight as I attempt to explain this keyword.

1 . This keyword (in object method):
Using this keyword in an object method ,  you can reference an object that you are currently in. This allows your code to become dynamic.
Example:

This keyword sets to the object that the method is called. I intend on expanding my knowledge on this topic in future posts. More information @The Mystery of This

 



Other than that, there wasn’t anything new I haven’t learned. On to the next part, Gordon Zhou emphasizes heavily in creating a ‘requirements’ list and then programming code under those select guidelines. By doing this, you concentrate solely on functionality and stay on the right path.

For his v3 objects requirements, he has the following.

  1. It should store the todos array on an object
  2. It should have  a displayTodos method
  3. It should have an add addTodo method
  4. It should have a changeTodo method
  5. It should have a deleteTodo method

I then attempt to code something up myself before watching the rest of the module. Here’s my attempt.

Code based on previous knowledge. The first day with WatchAndCode has been a success so far. I’ll see you tomorrow. 🙂

 

Thomas Nguyen

 

Leave a Reply

Your email address will not be published. Required fields are marked *