Object.defineProperty() – There’s More Than One Way to Skin a Cat

private property sign

definition: sketchy

I thought Id try and do something different for this blog and post some code that runs through how a specific piece of JavaScript Works

The Object.defineProperty() is a method that can create or modify a property of an object with a couple of special caveats added. Using this method you have the ability to make the property and the method read-only (writable and configurable) or invisible (enumearble).  For a more in depth explanation the Mozilla page can be found here and another very helpful blog on the method can be found here.

But this page is the copy of a JSFiddle post that I have been playing around with in an attempt to strengthen my understanding of it, you should give it a shot too. The link to the actually JSFiddle page can be found here.

 

Eloquent JavaScript and THAT Chapter

“goonies never say die, me on the other hand…”

So Im feeling like the definition of “spoke too soon” right now…

Just as just I released the previous blog raving about how good Eloquent JavaScript is, I came across Chapter 6 and the infamous “Laying Out a Table”.

This wasn’t fun.

Its a very complicated description about how to use JS to create a table script that has an even more complicated JavaScript program to follow along with. After staring at it for about 10 minutes, I picked up my jaw and started looking online for help. Luckily enough i found another blog post that I wanted to share: http://tomi.io/eloquent-javascript-laying-out-a-table/

Whilst this post doesn’t go over the actual problem itself, it does give you a very in depth explanation of what is actually happening, and you will be the better for it. Just remember to go slow and understand what you are learning.

Id thoroughly recommend you having a look at it when you get to Chapter 6.

Back to it.

Luke

Slow and Steady Wins the Race to Learn JavaScript

the new trailer for Fast and Furious 8 was surprisingly underwhelming

Like any good skill set, if you want to be successful at web development and JavaScript, you need to put in the time.

Along with learning JavaScript, for the past 3 years I’ve also been studying Japanese (the Human Japanese App is a great way to learn if you’re interested). Nearly every day I sit down for at least 30 minutes and go through the Japanese language with flash cards in order to reinforce my knowledge of the subject.

With my JavaScript studies this wasn’t the case though, instead of putting in the time, all I had been doing was running though the exercises as fast as I could in order to get to the next. I never really revised and only times I ever bothered looking back was when I needed to re-learn how a function performed… because I had already forgotten it. This was a problem, my understandings of the concepts of the JavaScript language were weak at best and my confidence in my abilities nosedived.

I recently started trying to introducing some of the study techniques (along with a couple of new ones) I utilise whilst studying Japanese, into my JavaScript studies, the results have been very encouraging and I have included them below:

  • Write what you are learning down in a text book, make sure to put it in your own words so you aren’t just copying and pasting
  • When coding, write down in the window what the code is about to perform and why (see below)
coding explanations

adding explanations to your coding helps reinforce what you have learned and also helps you if you need to come back to the code later

 

  • Make sure you 100% understand what you are attempting to learn before moving forward, if you don’t, go back and keep at it until you do
  • Spend 5 minutes at the end going over what you have learned, try and summarise
  • Spend the first 10 minutes of the new study period going through what you went through the last
  • If you have trouble remembering something specific, make up some flashcards and test yourself in your spare time
  • Break up your study periods into blocks, the Pomodoro Technique can be great for this
  • Remove distractions, this is a killer for me, out of an hour of study I can lose nearly 60% of that time just wondering what people are tweeting about or what delicious foods my girlfriend is instagramming atm, you will be much more effective if your phone is off and you are focused on the task at hand.
  • Take it slow, take it slow, take it slow, this isn’t a race, the more time you take to reinforce your understanding, the stronger you will be

So after recognising my mistake (and after I had stopped crying) I decided to go back to the start, but I didn’t go back to free code camp, I picked up the book Eloquent JavaScript by Marijn Haverbeke.

Now the book Eloquent JavaScript, in my small amount of experience, is about as intimidating as JavaScript books get; by about the third or fourth chapter the dial is turned up to 11 and you are thrown into the deep end without any floaties. This book can be so scary that there is a significant chance you may just end up throwing the thing in the fire and calling the whole thing off (something that can be especially expensive if you’re reading it from a kindle).

But please, please, please trust me, this book is fantastic and I couldn’t recommend it more, there are mountains of information to gain here, if you feel overwhelmed, just trust the process and take it slow, if you fail to understand something read it again and write it out, and if you still don’t understand by then, then go and jump on stack overflow, google the problem or even send me an email, there are heaps of resources out there to help. This book takes you on a very smart path to learning JS and I’ve really enjoyed slogging through it. Also as a bonus the book is available free in electronic format from his website so you don’t have to spend a dime (or ten cents if you live in Australia like me).

Good luck and keep moving (slowly) forward!

Luke