Starting to understand

Ramon Cruz-Hinojosa
2 min readMay 24, 2021

--

  • Describe one thing you’re learning in class today.

One thing I learned in class was that it’s good to plan my projects/homework out before I start so I don’t get lost halfway through the work. Whether that means I just psuedo code or make a checklist either way planning is great.

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

“Function Person (){}” is a user defined object with the name of Person, “var person = Person()” is assigning the function Person() to the variable person and “var person = new Person()” is making a new blank plain Javascript object named person that can be used to reference the original Person object.

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

An attribute is the initial state when rendered onto the DOM. A property is the current state anytime after everything has rendered onto the DOM. This question and answer to me are a bit harder to explain but for the most part attributes are things like an inputs type being text. <input type=”text”>. The properties are then accessible after the input has been rendered onto the DOM and could be for example alt or autofocus.

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

Both objects and arrays can be looped over using a regular for loop. It depends on what I would be trying to get out of the object or array I’m looping over. Another safe bet would be to use forEach on either an object or array making it a lot easier to write and read if all I’m going for is the property of an object or element in an array.

  • What is the event loop?

The event loop is the way that Javascript executes all operations. The event loop will que up whatever operation is next in line to be executed and remove that same operation from the line after it has finished to keep a steady flow of operations going.

  • What is the difference between call stack and task queue?

Here’s an example that explains this much better than I could.

So in short, a job queue is a queue of things to do (usually stored persistant) and a call stack is a stack of routines.

A job would have variables assigned to it, and a call stack would be the abstract implementation.

So a job could “call” a method from a call stack.

EDIT: There could be a list of jobs;

Resize foo.jpg to 100x100

Resize bar.png to 100x100

and each job would run a call stack multiple times;

First job

Copy foo.jpg into memory

Resize it to be 100x100

Store the resized foo.jpg in the thumbs folder

Second job:

  • Copy bar.png into memory
  • Resize it to be 100x100
  • Store the resized foo.jpg in the thumbs folder
  • What are the differences between ES6 classes and ES5 function constructors?

ES6 classes do the work of defining a new object and appending functions to its prototype. ES5 Function constructors work and look the same but the main difference is seen when the developer uses the Inheritance property.

--

--