Diving deeper into JavaScript.

It’s week…six?

Mary Wenzel
3 min readNov 9, 2020

Describe one thing you’re learning in class today.

Today we went over Objects in JavaScript,

an object being a standalone entity, like an object in real life that has its own properties and types. Compare it to your favorite pair of pants, the pants being the object while the properties are things like color, design, or material.

For example, creating an object in JavaScript would look something like this.

const myCar = {make: Toyota, model: Corolla LE, year: 2016};

In the line of code above myCar would be the object, while “make”, “ model”, and “year” are keys. And finally the value of the keys would be the properties of the object which in this case are “Toyota”, “Corolla Le”, and “2016”.

What’s the difference between: function Person(){}, var person = Person(), and var person = new Person()?

function Person(){}

This is a “Function Declaration”
This declares a function statement that performs an action but doesn’t execute it. Even though it doesn’t execute it, it’s saved into the global namespace which can be called later on in your code.

var person = Person() || const person = Person()

This is a “Function Expression”
The variable being ‘var person’ or how we would use it in class as ‘const person’ hold a value reference to the person function (‘Person()’).

var person = new Person() || const person = new Person()

This is a “Function Constructor”
By adding the word ‘new’, we are indicating that this is a function constructor.

What’s the difference between an “attribute” and a “property”?

An attribute would be a thing one would have in their HTML, while a property is a thing we access through JavaScript. A side by side would look like this,

HTML: <section id="cool-section”> JS property: section.id = cool-section;

What language constructions do you use for iterating over object properties and array items?

Array: for, forEach, for…of

Object: for loop, for..in, for each..in, Object.keys(), etc.

What is the event loop?

This is when JS executes all operations on a single thread, but using a few extra data structures, it gives off the illusion of multi-threading.

What is the difference between call stack and task queue?

The “call stack” keeps track of all the operations that are in line to be executed. Whenever a function is finished, it is popped from the stack.

The “event queue” is responsible for sending new functions out for processing. It follows the queued data structure to maintain the correct order in which the operations should be executed.

What are the differences between ES6 classes and ES5 function constructors?

This is confusing because ES5 Function constructors work and look the same as ES6 classes but the difference is in the inheritance property.

“ES6 classes” allow you to instantiate objects using the new operator while “ES5 function constructors” focus on how the objects are instantiated.

--

--