Loading...

Jammie Mountz

Software Engineer

JavaScript 101 – what trips up beginners

Here’s some common pitfalls JavaScript beginners fall into and their clarifications.

Object literals: “string.” 9 true
Expressions: a combination of object literals with operators (+-*/)
You can combine expressions to form compound expressions.
Expressions will “evaluate to” a result.
Anything outside of that result, e.g. something rendered on the browser/console, is a side effect.
An expression becomes a statement with the addition of the ; , such as an “if statement.”

Variables:
An assignment of a label to data that can be referred to later on. The expression itself is immediately evaluated on assignment

Objects:
literal notation
obj[‘key’] = “value”;
dot notation
obj.key = “value”
property lookup
console.log(obj[‘key’]);
console.log(obj.key);

For-In loops and For loops:
For-In will iterate through every property on an object.
For loops iterate through numbered properties, used on array.

Functions:
var myFunc = function(num){ return num; }
myFunc(3);
num is the parameter
3 is the argument
you can reference the arguments object within the function, which has a “length” property similar to an array.

Fluent in Spanish and JavaScript, salsa dancer, lover of material design.

Living in San Francisco, CA