Académique Documents
Professionnel Documents
Culture Documents
ET LEURS ATTRIBUTS
J AVA S C R I P T (Programmation Internet) V O L . V I
Po u r D é b u t e r
JDB DIASOLUKA Nz. Luyalu -2/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
JDB DIASOLUKA Nz. Luyalu -3/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
etc…
JDB DIASOLUKA Nz. Luyalu -7/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
etc…
ou
console.dir(HTMLAnchorElement.prototype)
JDB DIASOLUKA Nz. Luyalu -8/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
etc…
JDB DIASOLUKA Nz. Luyalu -9/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
etc…
JDB DIASOLUKA Nz. Luyalu -10/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
JDB DIASOLUKA Nz. Luyalu -11/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
div {
border:dashed medium hsl(324 , 69% , 81%);
border-radius : 7pt;
width : 15em; text-align : right
}
</style>
<script>
function jsCSS(){
let i = document.getElementById("iClass");
i.style.backgroundColor = " rgba(226,143,160,0.09)";
i.style.color = "hsl(282 , 30% , 24%)";
i.style.fontWeight = "900";
JDB DIASOLUKA Nz. Luyalu -13/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
i.style.textAlign = "center";
i.style.letterSpacing = "2";
i.style.textTransform = "capitalize";
// style = attribut (propriété) CSS
// backgroundColor et ... = valeurs d'attribut
}
</script>
:target (cible),
:disabled (inactivé),
JDB DIASOLUKA Nz. Luyalu -15/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
:optional (input, select ou textarea sans attribut
required),
:read-only,
JDB DIASOLUKA Nz. Luyalu -16/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
<script type="text/javascript">
"use strict";
var dObj = {
couleur:"rose",
50: "Cinquante",
age:45,
[2]:function(){console.log("Hello")},
3: "Trois",
["quatre"]:function(){console.log("quatre")}
}
console.log(dObj["couleur"])
console.log(dObj["50"])
console.log(dObj.age)
dObj[2]()
console.log(dObj[3])
dObj["quatre"]()
console.log("=====")
for(var i in dObj)console.log(i+". "+dObj[i])
console.log(Object.values(dObj))
console.log(">===<")
for(i in dObj)console.log(dObj[i])
</script>
Exécution :
rose test.html:14:3
Cinquante test.html:15:3
45 test.html:16:3
JDB DIASOLUKA Nz. Luyalu -17/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
Hello test.html:7:23
Trois test.html:18:3
quatre test.html:9:30
===== test.html:20:3
2. function(){console.log("Hello")} test.html:21:21
3. Trois test.html:21:21
50. Cinquante test.html:21:21
couleur. rose test.html:21:21
age. 45 test.html:21:21
quatre. function(){console.log("quatre")} test.html:21:21
Array [
dObj(), "Trois", "Cinquante", "rose", 45, dObj()
] test.html:22:3
>===< test.html:23:3
dObj()
length: 0
name: "2"
prototype: Object { … }
__proto__: function () test.html:24:17
Trois test.html:24:17
Cinquante test.html:24:17
rose test.html:24:17
45 test.html:24:17
dObj() test.html:24:17
length: 0
name: "quatre"
prototype: Object { … }
__proto__: function ()
JDB DIASOLUKA Nz. Luyalu -18/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
let _obj =
{"5":'ally', b:'belly', 3:'chore', _obj:45};
console.log(_obj._obj); // 45
o.sika1 = "Mosusu";
o["sika2"]="Mombamba";
console.log(o);
</script>
JDB DIASOLUKA Nz. Luyalu -19/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
Les propriétés sont des objets dont les propriétés sont leurs attributs.
JDB DIASOLUKA Nz. Luyalu -20/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
[[Enumerable]] Boolean Invisible dans certains contextes.
If true, the property will be enumerated
by a for-in enumeration (see 13.7.5).
Otherwise, the property is said to be
non-enumerable.
[[Configurable]] Boolean Peut être supprimée, ou
Son « property descriptor » changé.
If false, attempts to delete the property,
change the property to be an accessor
property, or change its attributes (other
than [[Value]], or changing [[Writable]]
to false) will fail.
Comme dit ci-dessus, [[value]] est la valeur que vous attribuez ou at-
tendez de l’objet.
console.log(Object.getOwnPropertyDescriptors(obj));
// Object { nom: {…}, matr: {…} }
// {…}
// matr: Object { value: 45, writable: true, enumerable:
true, … }
// nom: Object { value: "nomEl", writable: true, enumer-
able: true, … }
// {…}
// matr: {…}
// configurable: true
// enumerable: true
// value: 45
// writable: true
// nom: {…}
// configurable: true
JDB DIASOLUKA Nz. Luyalu -21/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
// enumerable: true
// value: "nomEl"
// writable: true
console.log(obj["nom"], obj.matr);
// nomEl 45
console.log(Object.getOwnPropertyDescriptor(obj,"nom"));
// Object { value: "nomEl", writable: true, enumerable:
true, configurable: true }
// {…}
// configurable: true
// enumerable: true
// value: "nomEl"
// writable: true
console.log(Object.getOwnPropertyDescriptor(
obj,"defProp"));
// Object { value: "definedProp", writable: false, enumer-
able: false, configurable: false }
// {…}
// configurable: false
// enumerable: false
// value: "definedProp"
// writable: false
</script>
JDB DIASOLUKA Nz. Luyalu -22/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
1. Définir une propriété : avec la méthode Object.defineProperty
[] = à fournir.
On peut définir les propriétés d’un objet [et éventuellement les attri-
buts de ces propriétés] de plusieurs façons ;
console.dir("obj.dirProp=",obj.dirProp);
// obj.dirProp= Direct Property
////////////////////////////
///// DÉBUT GETTER et SETTER
////////////////////////////
// Accès ordinaire
console.dir("obj=",obj);
// obj=
// Object { nom: "nomEl", matr: 45, dirProp: "Direct
Property", … }
// {…}
// defProp: "definedProp"
JDB DIASOLUKA Nz. Luyalu -24/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
// defPropA: "Affectation ordinaire, toujours pos-
sible!"
// defPropX: "definedProp Extended"
// dirProp: "Direct Property"
// matr: "2018"
// nom: "JavaScript"
// prod: Getter & Setter
// <get>: function get()
// <set>: function set()
console.log(Object.getOwnPropertyDescriptors(obj))
// Object { nom: {…}, matr: {…}, dirProp: {…}, defProp:
{…}, defPropX: {…}, prod: {…}, defPropA: {…} }
JDB DIASOLUKA Nz. Luyalu -25/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
// {…}
// defProp: Object { value: "definedProp", writable:
false, enumerable: false, … }
// defPropA: Object { value: "Affectation ordinaire,
toujours possible!", writable: true, enumerable: true, … }
// defPropX: Object { value: "definedProp Extended",
writable: false, enumerable: false, … }
// dirProp: Object { value: "Direct Property", writable:
true, enumerable: true, … }
// matr: Object { value: "2018", writable: true, enumer-
able: true, … }
// nom: Object { value: "JavaScript", writable: true,
enumerable: true, … }
// prod: Object { get: get(), enumerable: false, config-
urable: false, … }
/*
defProp: {…}
configurable: false
enumerable: false
value: "definedProp"
writable: false
defPropA: {…}
configurable: true
enumerable: true
value: "Affectation ordinaire, toujours possible!"
writable: true
defPropX: {…}
configurable: true
enumerable: false
value: "definedProp Extended"
writable: false
dirProp: {…}
configurable: true
enumerable: true
value: "Direct Property"
writable: true
matr: {…}
configurable: true
enumerable: true
value: 2018
JDB DIASOLUKA Nz. Luyalu -26/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
writable: true
nom: {…}
configurable: true
enumerable: true
value: "JavaScript"
writable: true
prod: {…}
configurable: false
enumerable: false
get: function get()
set: function set()
*/
</script>
var obj = {
libelle: 'Nom Produit',
JDB DIASOLUKA Nz. Luyalu -27/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
prix: 2018,
get detailsProd() {
return {nomProd:this.libelle, prixProd:this.prix};
},
set detailsProd(name) {
var parts = name.split(" ");
this.libelle = parts[0];
this.prix = parts[1];
}
};
console.log("obj=",obj);
// obj=
// Object { libelle: "Nom Produit", prix: 2018, details-
Prod: Getter & Setter }
// {…}
// detailsProd: Getter & Setter
// libelle: "ECMASCRIPT_2018"
// prix: "3USD"
console.log("obj.libelle=",obj.libelle);
// obj.libelle= Nom Produit
console.log("obj.prix=",obj.prix);
// obj.prix= 2018
console.log("obj.libelle=",obj.libelle);
// obj.libelle= ECMASCRIPT_2018
console.log("obj.prix=",obj.prix);
// obj.prix= 10
console.log(obj.prix = "3USD");
// 3USD
console.log("obj.detailsProd=",obj.detailsProd);
// obj.detailsProd=
// Object { nomProd: "ECMASCRIPT_2018", prixProd: "3USD"
}
JDB DIASOLUKA Nz. Luyalu -28/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
// {…}
// nomProd: "ECMASCRIPT_2018"
// prixProd: "3USD"
// AVEC YANDEX
//test.html:21 obj= {libelle: "Nom Produit", prix: 2018}
// detailsProd: (...)
// libelle: "ECMASCRIPT_2018"
// prix: "3USD"
// get detailsProd: ƒ detailsProd ()
// set detailsProd: ƒ detailsProd (name)
// __proto__: Object
//test.html:29 obj.libelle= Nom Produit
//test.html:32 obj.prix= 2018
//test.html:35 ECMASCRIPT_2018 10 USD
//test.html:38 obj.libelle= ECMASCRIPT_2018
//test.html:41 obj.prix= 10
//test.html:44 3USD
//test.html:47 obj.detailsProd = {nomProd:
"ECMASCRIPT_2018", prixProd: "3USD"}
/* obj.detailsProd =
1er {nomProd: "ECMASCRIPT_2018", prixProd: "3USD"}
A nomProd:"ECMASCRIPT_2018"
B prixProd:"3USD"
C __proto__:Object
1er detailsProd:(...)
2e libelle:"ECMASCRIPT_2018"
3e prix:"3USD"
4e get detailsProd:ƒ detailsProd()
5th set detailsProd:ƒ detailsProd(name)
JDB DIASOLUKA Nz. Luyalu -29/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
I 0:Global {type: "global", name: "", object: Wi
ndow}
1st set detailsProd:ƒ detailsProd(name)
A arguments:(...)
B caller:(...)
C length:1
D name:"set detailsProd"
E __proto__:ƒ ()
F [[FunctionLocation]]:test.html:13
G [[Scopes]]:Scopes[1]
I 0:Global {type: "global", name: "", object: Wi
ndow}
1er __proto__:Object
*/
</script>
et
N.B. : Les propriété ne peuvent avoir que soit des valeurs, soit des ac-
cesseurs (set et get) , jamais les deux à la fois.
var obj = {
libelle: 'Nom Produit',
prix: 2018,
get detailsProd() {
return {nomProd:this.libelle, prixProd:this.prix};
},
set detailsProd(name) {
var parts = name.split(",");
this.libelle = parts[0];
this.prix = parts[1];
}
};
// AFFECTER ou MODIFIER
console.log(obj.detailsProd = 'ECMASCRIPT 2018 ES 8, 10
USD AMÉRICAINS');
// ECMASCRIPT 2018 ES 8, 10 USD AMÉRICAINS
console.log("obj.libelle=",obj.libelle);
// obj.libelle= ECMASCRIPT 2018 ES 8
console.log("obj.prix=",obj.prix);
// obj.prix= 10 USD AMÉRICAINS
console.log("obj.detailsProd=",obj.detailsProd);
// obj.detailsProd=
// obj.detailsProd=
// Object { nomProd: "ECMASCRIPT 2018 ES 8", prixProd: "
10 USD AMÉRICAINS" }
// {…}
// nomProd: "ECMASCRIPT 2018 ES 8"
// prixProd: " 10 USD AMÉRICAINS"
</script>
Mots-clés :
JDB DIASOLUKA Nz. Luyalu -31/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
JDB DIASOLUKA Nz. Luyalu -32/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
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-
JDB DIASOLUKA Nz. Luyalu -33/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
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
• 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/Renseignements-Id-et-
Anthropometriques
• https://www.scribd.com/document/320856721/Emission-31-Jul-2016
• https://www.scribd.com/document/318182982/Complication-Visuelle-
du-Traitement-de-La-Malaria
• https://www.scribd.com/document/318180637/Rapport-Entre-
Oxymetrie-Et-Type-Respiration
• https://www.scribd.com/document/315746265/Classification-Des-
Medicaments
• https://www.scribd.com/document/315745909/Incongruences-
Heresies-et-Heterodoxies-de-la-Notion-de-Laboratoire
JDB DIASOLUKA Nz. Luyalu -34/35- dimanche, 16. juin 2019 (12:09 )
PROPRIÉTÉS & ATTRIBUTS D’OBJETS JavaScript Tome-VI
• https://www.scribd.com/document/315745725/Rapport-Entre-
Oxymetrie-Et-Type-Respiration
JDB DIASOLUKA Nz. Luyalu -35/35- dimanche, 16. juin 2019 (12:09 )