Object-oriented JavaScript quote
is written oriented-oriented*
When I define a relationship between one object and another by saying it’s a subtype
or derived type, I’m referring to the prototypal relationship that exists between the
objects. It’s important to clarify that although JavaScript is oriented-oriented, it
doesn’t have classical inheritance as you may have seen in other languages like Java.
be object-oriented
When I define a relationship between one object and another by saying it’s a subtype
or derived type, I’m referring to the prototypal relationship that exists between the
objects. It’s important to clarify that although JavaScript is object-oriented, it
doesn’t have classical inheritance as you may have seen in other languages like Java.
Code example about instantiating Student
is written p.fullname
var person = new Student('Alonzo', 'Church', '444-44-4444', 'Princeton');
p.fullname; // -> Alonzo Church
be person.fullname
var person = new Student('Alonzo', 'Church', '444-44-4444', 'Princeton');
person.fullname; // -> Alonzo Church
Code example about instantiating Student
is written (such as Student from Parent)
Figure 2.2 The focus of OOP is to create inheritance hierarchies (such as Student from Parent) with methods and data tightly bound together. Functional programming, on the other hand, favors general polymorphic functions that crosscut different data types and avoid the use of this.
be (such as Student from Person)
Figure 2.2 The focus of OOP is to create inheritance hierarchies (such as Student from Person) with methods and data tightly bound together. Functional programming, on the other hand, favors general polymorphic functions that crosscut different data types and avoid the use of this.
It said about using const
but didn't use it
is declared _lat
and _long
using let
In conjunction with const, you can create objects with semantics similar to those of a string or number. Let’s consider another example:
function coordinate(lat, long) {
let _lat = lat;
let _long = long;
return {
latitude: function () {
return _lat;
},
longitude: function () {
return _long;
},
translate: function (dx, dy) {
return coordinate(_lat + dx, _long + dy);
},
toString: function () {
return '(' + _lat + ',' + _long + ')';
}
};
}
be declared _lat
and _long
using const
In conjunction with const, you can create objects with semantics similar to those of a string or number. Let’s consider another example:
function coordinate(lat, long) {
const _lat = lat;
const _long = long;
return {
latitude: function () {
return _lat;
},
longitude: function () {
return _long;
},
translate: function (dx, dy) {
return coordinate(_lat + dx, _long + dy);
},
toString: function () {
return '(' + _lat + ',' + _long + ')';
}
};
}
Second code example
is calling fistname
method, but it wasn't created before
var person = Object.freeze(new Person('Haskell', 'Curry', '444-44-4444'));
person.firstname = 'Bob';
call _firstname
attribute
var person = Object.freeze(new Person('Haskell', 'Curry', '444-44-4444'));
person._firstname = 'Bob';
Second code example
is passing 'lastName'
to R.lenseProp
var person = new Person('Alonzo', 'Church', '444-44-4444');
var lastnameLens = R.lenseProp('lastName');
pass 'lastname'
to R.lensProp
var person = new Person('Alonzo', 'Church', '444-44-4444');
var lastnameLens = R.lensProp('lastname');
Third code example
is inverted the order of R.set
params
var newPerson = R.set(zipLens, person, zipCode('90210', '5678'));
be zipCode
first than person
var newPerson = R.set(zipLens, zipCode('90210', '5678'), person);