My Object/Array Scope #203

Describe one thing you’re learning in class today.

Today in class I learned about Objects and Arrays. An OBJECT is a collection of properties, and a property is an association between a name (or key) and a value. A property’s value can be a function, in which case the property is known as a method.

The ARRAY object lets you store multiple values in a single variable. It stores a collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

The above in its simplest terms sums the definition of both elements in Javascript, but with the theme of interpreting data flow in class now, we have added a new feature of understanding nested Objects and Arrays which would be the return of fetch( ) method when working with retrieving date from a database. Objects are made of key-value pairs, if we use the .keys() object method we will get the keys of all the key-value pairs in the objects. The properties of an object define the characteristics of the object. You access the properties of an object with a simple dot-notation.

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

1. function Person( ) {}
Declares a function (but does not execute it).
It will usually have some code between the curly brackets.

2. var person = Person( )
Declares a variable (person), invokes a function (Person) and sets the value of person to the return of the function.

3. var person = new person( )
Creates a new instance of an object based on the Person function. So the variable (person) is now an Object, not just a string or a number.

Objects can contain indexed strings, numbers and even functions, and you can add more stuff to them, they’re pretty awesome. The whole concept of Object Oriented Programming (OOP) is based on this.

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

Attributes are in the HTML itself, rather than in the DOM. They are very similar to properties, but not quite as good. When a property is available it’s recommended that you work with properties rather than attributes. An attribute is only ever a string, no other type.

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

For iterating over object properties you would have to start with a“for” loop. Then to have access to and manipulate the data within that object one could invoke several methods like object.keys( ) , object.values( ), or object.entries( ).

What is the event loop?

JavaScript has a concurrency model based on an event-loop, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks.

What is the difference between call stack and task queue?

In short, a job queue is a queue of things to do 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 cal stack.

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

ES5 function constructors work and look the same but the main difference is observed when the developer uses the Inheritance property. ES6 Class allows the developers to instantiate objects using the new operator. ES5 Function constructors focus on how the objects are instantiated.

Austin Coding Academy