For fun, I had ChatGPT take the free response section of the 2022 AP Computer Science A exam. (The exam also has a multiple-choice section, but the College Board doesn't publish this.) It scored 32/36.
- For each question, I pasted in the full text of the question and took the response given.
- I tried each question once and took the response given: no cherry-picking. For readability, I've added indentation in some cases, and included method signatures where they were provided in the question and ChatGPT only provided a body. I've added question numbers; any other comments are ChatGPT's.
- Many questions have examples containing tables or diagrams; because those don't translate well to plain text, I excluded those tables/diagrams and any text that referenced them.
- I excluded the initial instructions at the top of th
This document details some tips and tricks for creating redux containers. Specifically, this document is looking at the mapDispatchToProps
argument of the connect
function from [react-redux][react-redux]. There are many ways to write the same thing in redux. This gist covers the various forms that mapDispatchToProps
can take.
Redux is a collection of tools and techniques for managing a centralized "store". Essentially, your application state (your data) is kept in a central place (the store) and every part of the app that needs to read from that state does so in a controlled manner. At it's core, redux is mapping functional programming styles -- familiar to Lisp programmers -- to a modern JavaScript environment.
Many of the core concepts of react and redux can be found in other application frameworks like Angular and Ember. Classical (class based) frameworks like Ember provide a "kitchen sink" style API -- a prescriptive approach. Redux preaches a functional programming style, where composition and convention are preferred. This leads to a much smaller API but leaves a lot up to the developer.
This lack of a prescriptive API is freeing, but can lead to confusion when constructing your apps. It's up to the individual developer to follow best practices for separating concerns. The good
Zach Caceres
Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.
The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.
Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.
Method | Side effects1 | State updates2 | Example uses |
---|---|---|---|
Mounting | |||
componentWillMount |
✓ | Constructor equivalent for createClass |
|
render |
Create and return element(s) | ||
componentDidMount |
✓ | ✓ | DOM manipulations, network requests, etc. |
Updating | |||
componentWillReceiveProps |
✓ | Update state based on changed props |
// check version | |
node -v || node --version | |
// list locally installed versions of node | |
nvm ls | |
// list remove available versions of node | |
nvm ls-remote | |
// install specific version of node |
There is no way to store an empty object/array/null value. | |
There are also no actual arrays. Array values get stored as objects with integer keys. | |
(If all keys are integers, it will be returned as an array.) | |
Basically, it's one giant tree of hashes with string keys. | |
Simply write a value to any location, and the intermediary locations will automatically come into existance. | |
── Classes ── | |
DataSnapshot : Container for a subtree of data at a particular location. |
A curated collection of awesome & free JavaScript books to help you learn the JavaScript programming language.
If you know of any other free JavaScript books that you think should be on this list, please let me know in the comments section and I will get them added.