Intro to JS Week 3 — linking the back end to the front end

Monica Suarez
2 min readMay 17, 2020

This week we made sure our Tic-Tac-Toe game and Pig Latin translator functions were streamlined, and created GUIs to get them working on the browser so they can be played on the browser instead of our local terminal application. This gave me an opportunity to find out how to correct errors before executing the code on a web browser.

Describe one thing you’re learning in class today. | (Wednesday, May 13) Today we learned more about objects and why they are important in managing data storage. I also learned how to embed the debugger keyword into my code to find errors and make sure my functions execute the way I want them to.

Difference between: function Person(){}, var person = Person(), and var person = new Person()| function Person() {} — Declares a function but does not execute it. It will usually have some code between the curly brackets. var person = Person() — declares a variable (person), invokes a function (Person) and sets the value of person to the return of the function. var person = new Person() — creates a new instance of an object based on the Person function, so the variable (person) is now an object.

What’s the difference between an “attribute” and a “property”? | Attributes are defined by HTML, and all definitions inside HTML tag are attributes. They can only be strings. Properties belong to DOM, and the nature of DOM is an object in JavaScript. We can get and set properties as we do to a normal object in JavaScript and properties can be any data type.

What is the event loop? | An event loop is Code that waits for and dispatches events, handles the events for its environment, monitors the call stack and callback queue, and breaks down asynchronous code into ticks.

What is the difference between call stack and task queue? | Call stack is a data structure which keeps track of function calls in our program. When ever we call a function for its execution, we are pushing it to the stack. It is popped out of the stack when the execution is completed. Task queue is a JavaScript runtime messaging queue which handles task that is allocated by different web APIs. This queue is dedicated to handle the web APIs callbacks. The message are processed once the call stack is clear.

What are the differences between ES6 class and ES5 function constructors? | E5 is considered the “outdated,” function constructor where a function is declared with literally the word “function,” followed by a parameter, and a function within curly brackets. The E6 function constructor is an arrow notation, where the function is declared as a constant variable and the word function is no longer used at the beginning.

--

--