JS211 — Blog 203

Kasey
2 min readJun 1, 2021

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

These are different ways to declare a function.

function Person(){} — This is just a function declaration.

var person = Person() — This is an expression function, which just returns a value within the parentheses. This will se a variable called person as a function called Person().

var person = new Person() — this is a constructor function. In this case the a

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

From what I understand the property is like a variable and can be interacted with object in JS. These variables can be any type, like string, boolean, etc.

Attributes can only be strings, and would include all the information inside an HTML tag.

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

Objects = .keys() or for in loop
Arrays = .map() or for of loop

What is the event loop?

JS code runs one line at a time, so code cannot be ran in parallel, so an event loop gives the illusion that JS can be multithreaded. So, the event loop, basically takes functions/tasks from the task queue and sends the next task, if available and stack is empty.

What is the difference between call stack and task queue?

The task queue contains a list of functions waiting to be executed. While the call stack executes the functions for event loop.

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

ES5 is an older version of JS where a function is defined using the actual word function and must have a return, where as, ES6 adds the arrow function.

--

--