Let's Be Strict

Day 87 of Flatiron School

Seth

3 minute read

strict lady

Today I spent 30 mins pairing with one of the Learn instructors trying to work through some issues my Rails portfolio project has. Something I found out is that the project requirement to use a custom attribute writer instead of has_nested_attributes actually removes some functionality from the final app. Because of this lack of Rails magic one of my problems is harder to fix than expected. The other one is just a more simple if...else statement.

JavaScript is coming along and I’m happy it’s clicking more and more each day. It was definitely frustrating to have a rather solid grasp on a workflow, resources, and a knowledge base and then go back to almost nothing. I haven’t dove back in to the Mozilla Developer Network (MDN for short) docs but I know it’s coming soon.

Something that I ran across today in my IDE was a linting error from JSLint stating Missing "use strict" pragma on one of my functions. So, like a good dev I Googled this (well DuckDuckGo’ed this). I came to a great post and discussion about this on Stack Overflow. My takeaways were that using 'use strict'; enforces things that JavaScript allows to happen or will throw silent errors for. So, it basically forces a person to write their code correctly. However, this can be dangerous in legacy code. A great answer contained this gem IMO:

Where should I use ‘use strict’;?

  • In my new JavaScript application: Absolutely! Strict mode can be used as a whistleblower when you are doing something stupid with your code.
  • In my existing JavaScript code: Probably not! If your existing JavaScript code has statements that are prohibited in strict-mode, the application will simply break. If you want strict mode, you should be prepared to debug and correct your existing code. This is why using 'use strict'; does not suddenly make your code better.

I plan to add 'use strict'; to the top of every new JavaScript file I work on. I see no reason not to at this point in time and it’ll only enforce me writing better code in the end.

What do you think about 'use strict';? Leave it in the comments for me.

I also found out tonight from my Free Code Camp Nashville Co-Organizer Dave that he scored us a table at Music City Code 2017 which is pretty sweet. Not sure what we’re going to do with our table just yet so if you have ideas please let me know!

Time spent today: 3:07
Time spent total: 329:01
Lessons completed today: 5
Lessons completed total: 529

comments powered by Disqus