Today is the first day of my second week in General Assembly Boston’s Web Development Immersive program, a twelve-week, full-time course focused on JavaScript and Rails. The course is intended to take people from no knowledge of programming to a full-time position as a developer, so some of the past week has been review, but I’ve loved every single second of it. Instead of my standard-ish This Week I Learned posts for the next three months, I’m hoping to do quick weekly recaps of how the program’s going.
Day 1
We spend most of Day 1 on the command line interface and on git. A couple of cool things:
cd -
takes you to your previous working directory. SO HANDY.- use
git checkout -b newbranchname
to create a new branch and check out that branch simultaneously - I fixed my first-ever merge conflict!
- GA emphasizes frequent commits and long commit messages. This wasn’t part of the course, but I recently learned about Angular.js-style commits, which seem like a great way to organize and communicate.
Day 2
Day 2 was our first day working with JavaScript. A couple of new pieces of information/new conventions:
- Using let and const instead of var to declare variables. ES6 introduced these as a way to offer block scope. Eric Elliot explains in JavaScript ES6+: var, let, or const?.
- Some JavaScript hilarity (WAT)
- Not new, but a good reminder:
i++
(prefix increment) will returni
, then increment.++i
will increment, then return the new value of i. - Fat arrow functions.
Perhaps embarrassingly excited about fat arrow functions #SOCOOL #javascript #generalassembly
— RebekahHeacockJones (@rebekahredux) August 23, 2016
Day 3
- Seems obvious in hindsight, but you can isolate the unique elements in an array like this:
let words = ['lots', 'of', 'words', 'of', 'words']; let uniqueWords = {}; for (let i = 0, max = words.length; i < max; i++) { uniqueWords[words[i]] = true; }
This will give you an object where the keys are the unique elements in the array, and the values are
true
(as a convention; you can choose anything you want for the values). This is much simpler than my original approach, which involved…comparing all of the elements of the array to all of the elements? I don’t know. It was complicated and involved, and I don’t recommend it. Do this instead. If you want the final format to be an array, you can useObject.keys()
to extract the keys (the unique words) and store them in a new array.
Day 4
- Object properties are “attributes” when they point to values/primitives. Use constructor functions to attach attributes to an object.
- Object properties are “methods” when they point to functions. Use prototypes to attach methods to an object. (Why? Functions that are attached using a constructor will be copied and attached over and over again to each new instance of an object. This is a huge waste of memory.)
- Properties that begin with underscores are private (by convention): not intended for direct access or assignment.
- “accumulator pattern” (all of the online resources I can find about this talk about it in Python, but it applies in other languages): initialize result, iterate, return result
- We started using node to run and test scripts.
- A callback is a function that is passed as a parameter to and executed inside of another function.
Day 5
- When filtering and transforming an array (
arrresultsresults[i]
within anif
statement can result in “holes” in the array when the originalarr[i]
doesn’t pass the filter. It’s better to useresults.push
to skip values that don’t pass, resulting in a cleanerresults
array. - Template literals (WHAAAAAAAAT so cool).
HOW DID I NOT KNOW ABOUT TEMPLATE LITERALS https://t.co/JHA4CXKcJv #teamnomoreplussigns #syntacticsugar #generalassembly
— RebekahHeacockJones (@rebekahredux) August 26, 2016
To sum up the week:
So deeply in my happy place right now that I can barely handle it. #generalassembly @ General… https://t.co/cGWFup2yW7
— RebekahHeacockJones (@rebekahredux) August 26, 2016
You definitely are a geek — about whatever you are doing. One of your better qualities I might add.