Javascript Intermediate 10 - Class syntax in Javasript as an abstraction from prototypical inheritance
Distinction between fields and properties
Within a class body, there are a range of features available.
The structure of a class definition via the class keyword is
class MyClass {
// Constructor
constructor() {
// Constructor body
}
// Instance field
myField = "foo";
// Instance method
my...
Javascript Intermediate 9 - Inheritance model with a prototype chain, a demostration with pseudoclassical inheritance
Runtime Code vs Library Code
First of lets clarify a distinction between the following concepts in a programming language.
Core or runtime code of a Programming language: Defines the interpreter or compiler
Library Code : Code written on the same programming language (same level of abstraction) that defines basic functionalities that every...
Javascript Intermediate 8 - Differences between __proto__ and .prototype on Constructor Functions
Now that we have established the relationship between instanceObject.__proto__ (we are going to use Object.getPrototypeOf()) , and Constructor.prototype we see that.
function Food () {
}
var popcorn = new Food();
console.log(Object.getPrototypeOf(popcorn) === Food.prototype); // True
We can set its prototype properties as
function Food () ...
Javascript Intermediate 7 - Differences between __proto__ and .prototype on Objects
In its most basic form proto is a built-in property in all objects in JS , that you set to other object so it inherits its properties.
The firstObject will inherit secondObjects properties , and the properties of the secondObject.proto object and so on.
let tangible = {
isTouchable: true
}
let resource = {
hasUtility: true,
__proto_...
Javascript Intermediate 6 - What is a prototype
First off
All object literals in javascript inherit from Object.prototype global object
var myObject = { };
console.log(myObject instanceof Object); // True
console.log(myObject instanceof Function); // False
Also, out of the inheritance model we can say that
Javascript objects have a property called prototype accessed as proto ,...
Javascript Intermediate 5 - About scoping var, let, const
Global-Scope vs Local-Scope
In terms of the call-stack Global-Scope vs Local-Scope
Global Scope:
The global scope represents the outermost scope in JavaScript.
Variables and functions declared in the global scope are accessible from anywhere in the script.
When a JavaScript program starts executing, the global scope is created and remai...
Javascript Intermediate 4 - Object Data Properties vs Accesor Properties
In the same way you can create Accesor properties which are a bit different.
Associates a key with one of two accessor functions ( get and set ) to retrieve or store a value.
An accessor property has the following attributes:
get
A function called with an empty argument list to retrieve the
property value whenever a get access to ...
Javascript Intermediate 3 - Object data properties and its descriptors
Javascript Intermediate 3 - Object data properties and its descriptors
Internaly each object data property has a set of attributes that are called descriptors,
Dont confuse the attributes of a property with properties of a property,
The attributes of a property are the further most division of an Object
These are the following
value:
...
32 post articles, 4 pages.