JS Notes

Variables

Creating variables

You create a variable with the keyword var followed by a name for your variable. You can then assign a value to your variable with an equals sign (=) followed by the value you want to give it.
  • Variable var keyword
  • Name of variable
  • Assign value with =
  • Value you want to give

Example:

var randomNumber = Math.floor(Math.random() *100) +1;

In the last example, var just states "I'm creating a new variable", randomNumber is setting a name to the variable, the = is to define what the value of that variable is going to be and the next piece of code is the value itself.

Functions

Functions are reusable blocks of code that you can write once and run again and again, saving the need to keep repeating code all the time. This is really useful. There are a number of ways to define functions, but for now we'll concentrate on one simple type. Here we have defined a function by using the keyword function, followed by a name, with parentheses put after it. After that we put two curly braces ({ }). Inside the curly braces goes all the code that we want to run whenever we call the function.

Creating a function

  • function keyword
  • nameOfTheFunction() Name of the function followed by open and close brackets
  • The actual function inside {}

 

Questions JS.01

At this point, after learning how to "create" a variable and a function, here are some questions that I have.

  • When do I use a function?
  • What are the multiple pieces of a function?
  • What is the typical structure I need to feel in of a "program" using variables and functions?
  • Are variables and functions the only foundational pieces?
  • What other pieces do I have to start building up my program?
  • What are the relationship between variables and functions?

Operators

They're mostly math operators (+,-,*,/). They work both in the console and in the code.

You can also use the + operator to join text strings together (called concatenation in programming).
There are also some shortcut operators available, called augmented assignment operators. 
nameOfTheVariable += 'some string here';
This is equivalent to

nameOfTheVariable = nameOfTheVariable + 'some string here';

Operator Name Example

  • === Strict equality (is it exactly the same?)
    • 5 === 2 + 4
  • !== Non-equality (is it not the same?
    • 'Chris' !== 'Ch' + 'ris'
  • < Less than
    • 10 < 6
  • > Greater than
    • 10 > 20

Conditional

A conditional looks look a function, but it isn't.


A conditional code block allows you to run code selectively, depending on whether a certain condition is true or not. It looks a bit like a function, but it isn't. The simplest form of conditional block starts with the keyword if, then some parentheses, then some curly braces. Inside the parentheses we include a test. If the test returns true, we run the code inside the curly braces. If not, we don't, and move on to the next bit of code.

  • if
  • (test goes here)
  • {code to run if test is true}

 

Questions JS.02

  • Can I use " instead of '?
  • What's the difference between working at the console level and a file level?
  • Why does the console returns "undefined"?
  • Why can a variable be declared inside of a function?
  • When does a variable is lives outside or inside of a function?
  • What's the structure of a function?
  • What are the canonical examples of a function?
  • How do I have access to HTML/CSS properties?
  • When do I need to write something next to parenthesis likeThis()? When is it necessary?
  • What does () mean?
  • What are the in built methods that I have access? How can I know all these methods, how to use them, and in which situations?

[syllabus.03] Iteration & reduction

This was the original list:

  1. February: P5.JS
  2. March: Swift
  3. April: Origami
  4. May: AfterEffects
  5. June: Unity
  6. July: RoR / build an API
  7. August: Cellphone / Arduino / Hardware hacking
  8. September: Openframe / Raspberry Pi
  9. October: Urban farming
  10. November: Python / Data mining
  11. December: Pure data

This is how that list can be if it's categorized in disciplines:

Design

  • Origami
  • Unity
  • AfterEffects

Programming

  • P5JS
  • RoR / build an API
  • Swift
  • Python / Data mining

Hardware

  • Cellphone / Arduino / Hardware hacking
  • Openframe / Raspberry Pi

Other

  • Urban farming
  • Pure data

 

I also figured out that I can reduce by a half the topics that I want to approach:

  • Origami
  • P5JS, PaperJS
  • RoR / build an API
  • Python / Data mining
  • Cellphone / Arduino / Hardware hacking
  • Openframe / Raspberry Pi
 

Projects

  • Interfaces. Origami, After Effects
  • Build a web app that collects information that I like. APIs, servers, product.
  • Tracking MX government numbers. Python, RaspberryPi, server
  • Cellphone. Arduino, hardware hacking
  • Openframe. Raspberry Pi, servers, hardware hacking, industrial design.

Science disciplines

Something that would be more difficult to even try to learn but will actually be substantial for everything else will be to learn and practice disciplines: physics, mathematics, calculus. But I guess it will requiere a lot of time and I can lear some of those concepts by intersecting it with other branches of knowledge. Like learn physics by making video games and learning math by making some hardware hacking.

Nevertheless, I'm gonna try to study some core topics of physics and math.

Learning to draw (again) & controllers

Two other things that I'm also interested in learning/working are:

  • Alternative controllers. I want to design and potentially build a couple of alternative controllers. I'm interested in alternative and kinetic I/Os. Things like a rounded controller, soft controllers, motion controllers, 3D controllers, sound controllers, light controllers, etc.
  • Learning to draw based on imitating artists and illustrators I really admire. The exercise will consist of actually copying and studying drawings by my favorite drawers. No creativity needed.

[note] Formal vs Informal

One determining thought before distributing my learning hours will be the formal vs the informal. How much time do I spend reading about computing, technology, arts and design systems in general, and how much do I spend tackling a specific skill, like "using Python to data mining Mexican government's APIs".

I need to come up with something.

[syllabus.02] Tracing a calendar

From my last post, I extracted these:

Criteria

  • I can choose 12 topics/projects and execute 1 per month.
  • I can choose 52 exercises and try to execute one per week, more on a sprint mode.
  • I can choose 4 topics and spend 3 months on each one.
  • The last option is to choose 3 topics and spend 4 months on each one.

Topics

  • P5.JS
  • Two.JS
  • Swift
  • Pure Data
  • After Effects
  • Origami
  • Unity
  • Data mining [see Python]
  • Python [see Data mining]
  • Blender
  • Hardware hacking (learn to use the Raspberry Pi, Arduino or any other HH board)
  • Urban farming
  • RoR / [build an] APIs
  • Openframe
  • Cellphone
  • Raspberry Pi / [how to set up a] server
  • Art / installation [see RPi]

Notes & after thoughts:

  • The categorization between topics and projects doesn't help that much.
  • Choosing 3 topics to spend 4 months on each topic sounds like the least exciting discipline.
  • Learning one thing per week is not going to make me an expert on any thing. Nevertheless, I don't want to be an expert, but yet, I want to accomplish some things.
  • Even though the constraint of "time" is not the best metric to accomplish depth on a topic or discipline, it does help to boost the energy into accomplishing something.

If I distribute the topics through out a year for every month, it would just encompass the next projects:

  1. February: P5.JS
  2. March: Swift
  3. April: Origami
  4. May: AfterEffects
  5. June: Unity
  6. July: RoR / build an API
  7. August: Cellphone / Arduino / Hardware hacking
  8. September: Openframe / Raspberry Pi
  9. October: Urban farming
  10. November: Python / Data mining
  11. December: Pure data

If I just pick 4 topics for the year, it would probably look like this:

  1. Q1: Programming: P5JS, Python / Data mining
  2. Q2: After Effects, Origami, design prototyping
  3. Q3: Urban Farming
  4. Q5: Hardware hacking, Raspberry Pi, Arduino, Cellphone, Openframe

Some problems with all these topics is that I actually don't have that much time through out the year to learn so many things. So the dilema is: should I learn a little bit of a lot of things or should I try to learn less (let's say, just one thing, but better) through the year? One problem with trying to learn just one thing is that, invariably, I'm going to find a lot of obstacles on any selected topic and it's quite probable that it's not gonna have to be with me, but with some external factor (the chosen language can't run on my computer, the latest update broke my project, it's not good timing to practice urban farming).

[syllabus.00] Things I want to learn

Here's a [master] list of the topics I'm interested in learning [2017]:

  • P5.JS
  • Two.JS
  • Swift
  • Pure Data
  • After Effects
  • Origami
  • Unity
  • Data mining [see Python]
  • Python [see Data mining]
  • Blender
  • Hardware hacking (it can be from learning how to use an Arduino to making a specific hardware hacking project)
  • Urban farming
  • RoR / [build an] APIs
  • Openframe
  • Cellphone
  • Raspberry Pi / [how to set up a] server

This is an un-going list that will contract and expand depending on my interests.