Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
// console.log("i.auj = ",i.auj());
// TypeError: i.auj is not a function
</script>
}
}
console.log(Quad.quad()); // 4
console.log(Quad.quad(5)); // 20
// quad() de la class Quad
console.log(DbleQuad.quad(3)); // 144
// quad() de la classe DbleQuad
</script>
I. Classes en JavaScript :
ECMAScript is object-based: basic language and host facilities are provided by objects,
and an ECMAScript program is a cluster of communicating objects. An ECMAScript
object is a collection of properties each with zero or more attributes that determine
how each property can be used—for example, when the Writable attribute for a proper-
ty is set to false, any attempt by executed ECMAScript code to change the value of the
property fails. Properties are containers that hold other objects, primitive values, or
functions. A primitive value is a member of one of the following built-in types: Unde-
fined, Null, Boolean, Number, and String; an object is a member of the remaining
built-in type Object; and a function is a callable object. A function that is associated
with an object via a property is a method.
ECMAScript defines a collection of built-in objects that round out the definition of
ECMAScript entities. These built-in objects include the global object, the Object ob-
ject, the Function object, the Array object, the String object, the Boolean object, the
Number object, the Math object, the Date object, the RegExp object, the JSON ob-
ject, and the Error objects Error, EvalError, RangeError, ReferenceError, Syn-
taxError, TypeError and URIError.
congrat() {
console.log("Hello,",this.id);
// Hello, Brejnev.
}
}
Person.prototype.congrat = function() {
console.log("Hello,",this.id);
}
this.msg = function () {
console.log(`Objet: Nom= ${this.name}`,
`Matr=${this.matr}`);
}
msg() {
console.log(`class: Nom= ${this.name}`,
`Matr=${this.matr}`);
}
}
console.log(
new Rect(3,4).name, // Rect
new Rect(3,4).length, // undefined
new Rect(3,4).width, // 4
new Rect(3,4).height, // 3
new Rect(3,4).surf(), // 12
);
console.log(
new Rect(5).name, // Rect
new Rect(5).length, // undefined
new Rect(5).width, // 5
new Rect(5).height, // 5
new Rect(5).surf(), // 25
);
</script>
Les fonctions liées aux classes sont exécutées en mode strict quel
que soit le mode de JS.
Firefox 64 :
Yandex :
Firefox 64 :
Yandex :
Expression simple :
console.log(vClass.name); // ClassName
</script>
clause() {
return(this.nom + ' sollicite ' +
this.montant + this.devise);
}
}
clause() {
return(
`${this.nom} ( ${this.aspect} )`+
` rembourse ${this.montant} ${this.devise}`
);
}
}
clause() {
let retval= `${this.nom} ( ${this.aspect} ) `+
`sollicite ${this.montant} ${this.devise}`+
`( ${this.raison} )`;
if(!this.credi) retval+=", refusé";
else retval+=", accordé ";
return retval;
// Debiteur hérite de « nom » et « montant » de Creancier.
}
}
Voiture.prototype.roule = function () {
console.log(this.nom + ' file très vite.');
// Ferari file très vite.
}
Prototype et « super » !
class deRally {
constructor(nom) {
this.nom = nom;
}
roule() {
super.roule();
console.log(this.nom + ' traîne.');
}
}
Object.setPrototypeOf(deRally.prototype, Voiture);
// Donne accès aux méthodes de Voiture.
get idName() {
console.log(this._idName,"- de get");
return this._idName;
}
set idName(value) {
console.log("Ds setter.");
if (value.length < 4) {
console.log("idName trop court.");
return;
}
this._idName = value;
}
}
Exécution-tracée:
console.log("==========");
Mots-clés :
diasfb@mail2world.com
Autre Lecture :
https://www.scribd.com/document/374738470/Le-Plus-Grand-Secret-de-La-
Creation
• https://www.scribd.com/document/377036251/Le-
Dosage-Des-Medicaments-en-Cac-Cas
• https://www.scribd.com/document/377035454/Le-
Hasard-Des-Thermometres-Non-contact-a-Infrarouge
• https://www.scribd.com/document/376222482/Petite-
Introduction-Aux-Fonctions-JavaScript
• https://www.scribd.com/document/376221919/La-Foi-
en-Jesus-Christ-Pour-Quoi-Faire
• https://www.scribd.com/document/375689778/Lacuite-
visuelle-angulaire
• https://www.scribd.com/document/375349851/La-
variable-This
•
https://www.scribd.com/document/375024162/Fonctions-
Imbriquees-en-JS
• https://www.scribd.com/document/374789297/Format-
Interne-Des-Objets-JavaScript
•
https://www.scribd.com/document/374788758/Iterations-
en-JavaScript
• https://www.scribd.com/document/374738470/Le-Plus-
Grand-Secret-de-La-Creation
• https://www.scribd.com/document/374597969/Nouvelle-
Formule-d-IMC-indice-de-doduite-Selon-Dr-Diasoluka
• https://www.scribd.com/document/373847209/Property-
Descriptors
• https://www.scribd.com/document/373833282/l-Objet-
Global-Window
•
https://www.scribd.com/document/372665249/Javascript-
Tome-II
J.D.B. DIASOLUKA Nz. Luyalu 24 / 25 JavaScript Tome-
III
Les CLASSES en JavaScript
• https://www.scribd.com/document/355291488/motilite-
oculaire-2
• https://www.scribd.com/document/355291239/motilite-
oculaire-I
• https://www.scribd.com/document/355290248/Script-d-
Analyses-Des-Reflexes-Pupillomoteurs
•
https://www.scribd.com/document/321168468/Renseigne
ments-Id-et-Anthropometriques
•
https://www.scribd.com/document/320856721/Emission-
31-Jul-2016
•
https://www.scribd.com/document/318182982/Complicati
on-Visuelle-du-Traitement-de-La-Malaria
• https://www.scribd.com/document/318180637/Rapport-
Entre-Oxymetrie-Et-Type-Respiration
•
https://www.scribd.com/document/315746265/Classificati
on-Des-Medicaments
•
https://www.scribd.com/document/315745909/Incongruen
ces-Heresies-et-Heterodoxies-de-la-Notion-de-
Laboratoire
• https://www.scribd.com/document/315745725/Rapport-
Entre-Oxymetrie-Et-Type-Respiration