javascript - les strings

Transcription

javascript - les strings
Les Strings (Chaînes de Caractères)
Pour Débutant
J AVA S C R I P T (Programmation Internet) V O L . X X I I
J.B. Dadet DIASOLUKA Luyalu Nzoyifuanga
+243 - 851278216 - 899508675 - 995624714 - 902263541 - 813572818
[email protected]
LES STRINGS :
Les Strings ne sont structurellement ni plus ni moins qu’une forme spéciale
d’Array d’éléments de même nature et même taille (des valeurs entières
non-signées représentées sur 16 bits) avec des propriétés et méthodes en
plus ou en moins dans leurs constructeurs et leurs prototypes, par rapport
aux Arrays. Les éléments y sont indexés, ordonnés dans le même ordre que
dans la chaîne saisie, et numérotés à partir de l’indice 0 (zéro). Voici ce
qu’on obtient à la console.
>> Object.getOwnPropertyDescriptors("Dias")
Object { 0: {…}, 1: {…}, 2: {…}, 3: {…}, length: {…} }
==========
>> Object.getOwnPropertyDescriptors(["D","i","a","s"])
Object { 0: {…}, 1: {…}, 2: {…}, 3: {…}, length: {…} }
====================
>> Object.getOwnPropertyDescriptors("Dias")
{…}
0: Object { value: "D", writable: false, enumerable:
1: Object { value: "i", writable: false, enumerable:
2: Object { value: "a", writable: false, enumerable:
3: Object { value: "s", writable: false, enumerable:
length: Object { value: 4, writable: false,
false, … }
<prototype>: Object { … }
__defineGetter__: function __defineGetter__()
__defineSetter__: function __defineSetter__()
true, … }
true, … }
true, … }
true, … }
enumerable:
DIASOLUKA Nz. Luyalu
JavaScript
__lookupGetter__: function __lookupGetter__()
__lookupSetter__: function __lookupSetter__()
constructor: function Object()
hasOwnProperty: function hasOwnProperty()
isPrototypeOf: function isPrototypeOf()
propertyIsEnumerable: function propertyIsEnumerable()
toLocaleString: function toLocaleString()
toSource: function toSource()
toString: function toString()
valueOf: function valueOf()
==========
>> Object.getOwnPropertyDescriptors(["D","i","a","s"])
{…}
0: Object { value: "D", writable: true, enumerable: true, … }
1: Object { value: "i", writable: true, enumerable: true, … }
2: Object { value: "a", writable: true, enumerable: true, … }
3: Object { value: "s", writable: true, enumerable: true, … }
length: Object { value: 4, writable: true, enumerable:
false, … }
<prototype>: Object { … }
__defineGetter__: function __defineGetter__()
__defineSetter__: function __defineSetter__()
__lookupGetter__: function __lookupGetter__()
__lookupSetter__: function __lookupSetter__()
constructor: function Object()
hasOwnProperty: function hasOwnProperty()
isPrototypeOf: function isPrototypeOf()
propertyIsEnumerable: function propertyIsEnumerable()
toLocaleString: function toLocaleString()
toSource: function toSource()
toString: function toString()
valueOf: function valueOf()
Exemple dans un code :
<script type = "text/javascript">
var str = "Un chasseur sachant chasser sans son chien est un
bon chasseur";
Les Strings
-2/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
console.log("str = ", str);
JavaScript
console.log("str.slice(5,10)", str.slice(5,10));
console.log("str = ", str);
console.log("str.fill(5,10)", str.fill(5,10));
console.log("str = ", str);
</script>
str = Un chasseur sachant chasser sans son chien est un bon
chasseur
test.html:3:4
str.slice(5,10) asseu
test.html:5:4
str = Un chasseur sachant chasser sans son chien est un bon
chasseur
test.html:6:4
TypeError: str.fill is not a function
test.html:8:34
Les chaînes de caractères en JavaScript sont immuables, c’est-à-dire que
contrairement au langage C, en JavaScript une fois une chaîne créée, elle ne
peut plus être modifiée.
Mais la lecture des parties de la chaîne, la concaténation et le remplacement
via une « expression régulière » restent possibles, ce qui en fait ne modifient pas la partie du texte déjà saisi (sauf avec l’expression régulière). Mais
aussi on peut saisir une nouvelle chaîne dans la même variable (mais qui
Les Strings
-3/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
naturellement n’aura pas nécessaireent la même taille), mais cela nous permet une astuce de contourner cette restriction : la modification/mutation
d’une chaîne [de caractères] dans JavaScript.
À la console du browser :
Dans un code :
<script type = "text/javascript"> "use strict";
let s = "DiaHoluka";
console.log(s);
let a = Array.from(s);
console.log(a);
a[3] = "s"
console.log(a);
s = a.join()
Les Strings
-4/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
console.log(s);
JavaScript
s = s.replace(/,/g, e => "");
console.log(s);
</script>
Si on ne maîtrise pas les « expressions régulières » ou si on ne veut pas les
utiliser, on peut bien sûr mettre ce processus dans une fonction :
<script type = "text/javascript"> "use strict";
// Contrairement aux fonctions traditionnelles,
// une fonction fléchée DOIT être définie
// AVANT sa première utilisation.
const sreplace = (str,pos,substr) => {
const a = Array.from(str);
a[pos]=substr;
return a.join().replace(/,/g, e => "");
}
const s = "DiaHoluka";
console.log(s); // DiaHoluka
console.log(sreplace("DiaHoluka",3,"s"));
// Diasoluka
console.log(sreplace("DiaHoluka",4,"salé"));
// DiaHsaléluka
</script>
Notez que la chaîne initiale reste intacte :
Les Strings
-5/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
La taille ou longueur (length) d'une chaîne de caractères est le nombre
d'éléments 16 bits que la chaîne contient :
Une méthode intéressante de « String » est le callback « replace » qui permet de remplacer les caractères dans une chaîne selon un critère spécifié
dans une expression régulière « RegExp ».
<script> "use strict";
function convertirVoyels(s) {
return s.replace(/[aeiouy]/g, function(e) {
return e.toUpperCase();
});
}
function convertirConsonnes(s) {
return s.replace(/[^aeiouy]/g, function(e) {
return e.toUpperCase();
});
}
function convertirEnMaj(s) {
return s.replace(/[a-z]/g, function(e) {
return e.toUpperCase();
});
}
function convertirEnmin(s) {
Les Strings
-6/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
return s.replace(/[A-Z]/g, function(e) {
return e.toLowerCase();
});
}
console.log(convertirVoyels(
"Lelo ya yo moko, Lobi ya bino
console.log(convertirConsonnes(
"Lelo ya yo moko, Lobi ya bino
console.log(convertirEnMaj(
"lelo ya yo moko, lobi ya bino
console.log(convertirEnmin(
"LELO YA YO MOKO, LOBI YA BINO
</script>
mibale"));
mibale"));
mibale"));
MIBALE"));
L’opérateur « ... » (spread operator) :
L’opérateur « ... » (spread operator) convertit une String en une Array dont
les éléments restent dans l’Arrayt quand le tout est entouré de crochets, et
seulement affichés quand le tout n’est pas entouré de crochets.
<script> "use strict";
console.log(new Date().getFullYear());
console.log(`${new Date().getFullYear()}`);
console.log(...`${new Date().getFullYear()}`);
console.log([...`${new Date().getFullYear()}`]);
console.log("=".repeat(33));
for(let i of [...`${new Date().getFullYear()}`])
console.log(i);
</script>
Les Strings
-7/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
Pour extraire uns sous-chaîne d’une autre chaîne :
Pour manipuler/extraire chaque caractère d’une chaîne, on peut utiliser la
boucle « for…of » :
<script> "use strict";
for (let i of 'Année 2018')
console.log(i);
</script>
Les Strings
-8/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
Les Strings
JavaScript
-9/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
UN MÉLIMÉLO DES MÉTHODES DE STRING :
<script> "use strict";
console.log("Diasoluka".includes("so",3));
console.log("Diasoluka".search("sol"));
console.log("Diasoluka".indexOf("sol"));
console.log("Diasoluka".lastIndexOf("a"));
console.log("Diasoluka".substr(3,3));
console.log("Diasoluka".substring(3,6));
console.log("Diasoluka".endsWith("luka"));
console.log("Diasoluka".endsWith("oluk",8));
console.log("Diasoluka".endsWith("solu",7));
console.log("Diasoluka".startsWith("Diaso"));
console.log("Diasoluka".startsWith("diaso"));
console.log("Diasoluka".startsWith("solu",3));
console.log("Diasoluka".slice(2,5));
console.log("Diasoluka".slice(-5,-1));
console.log("DiaSolUka".toLocaleLowerCase());
console.log(`"
DiaSolUka
// "
DIASOLUKA
"
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
true
3
3
8
sol
sol
true
true
true
true
false
true
aso
oluk
diasoluka
"`.toLocaleUpperCase());
console.log("'"+`${"
// 'DiaSolUka'
DiaSolUka
".trim()}`+"'");
console.log("'"+`${"
// 'DiaSolUka '
DiaSolUka
".trimLeft()}`+"'");
console.log("'"+`${"
// 'DiaSolUka '
DiaSolUka
".trimStart()}`+"'");
console.log("'"+`${"
// ' DiaSolUka'
DiaSolUka
".trimRight()}`+"'");
console.log("'"+`${"
// ' DiaSolUka'
DiaSolUka
".trimEnd()}`+"'");
console.log("Diasoluka".split("a"));
// (3) ["Di", "soluk", ""]
Les Strings
-10/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
console.log("Diasoluka".replace(/[aeiouy]/g, e => "_"));
// D__s_l_k_
console.log("Diasoluka".replace(/[aeiouy]/g, e => ""));
// Dslk
console.log("Diasoluka".replace(/[aeiouy]/g, e =>
`${Math.round(Math.random()*10)}`));
// D98s4l9k4
console.log("Diasoluka".match("solu"));
// ["solu", index: 3, input: "Diasoluka", groups: undefined]
console.log(`so${Math.pow(2,10)}lu`);
// so1024lu
console.log(`so\nlu`);
// so
// lu
console.log(String.raw`so\nlu`);
// ["solu", index: 3, input: "Diasoluka", groups: undefined]
let n=Number(40);
console.log(typeof n.toString());
// string
console.log(typeof n.toString().valueOf()); // string
console.log(typeof n.toLocaleString());
// string
console.log("Teuf ".repeat(3));
console.log("Teuf".padStart(10,"-"));
console.log("Teuf".padEnd(10,"-"));
//
// Teuf Teuf Teuf
// ------Teuf
// Teuf------
console.log(String("Teuf").padLeft (10,"-"));
// TypeError: String(...).padLeft is not a function
//
console.log("Teuf".padRight (10,"-"));
// TypeError: "Teuf".padRight is not a function
</script>
« TypeCasting » vers une String :
Les Strings
-11/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
Au besoin, la fonction « String(obj) » ou la méthode « obj.toString() »
convertissent la valeur primitive d’un objet en chaîne.
<script type="text/javascript"> "use strict";
var x = _ => ["A",1,{a:"a"},["y",{2:"deux"}]];
console.log(x().toString());
// A,1,[object Object],y,[object Object]
console.log(String(x()));
// A,1,[object Object],y,[object Object]
</script>
Object . toString ( ) s’applique aux objets suivants :
Object
Behavior
Array
Elements of an Array are converted to strings. The resulting strings are
concatenated, separated by commas.
Boolean
If the Boolean value is true, returns "true". Otherwise, returns "false".
Date
Returns the textual representation of the date.
Error
Returns a string containing the associated error message.
Function
Returns a string of the following form, where functionname is the
name of the function whose toString method was called:
function functionname( ) { [native code] }
Number
Les Strings
Returns the textual representation of the number.
-12/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
Object
Behavior
String
Returns the value of the String object.
Default
Returns "[object objectname]", where objectname is the name of the
object type.
La méthode « .toString » permet aussi de convertir un nombre d’une
base de numération vers une autre.
<script type="text/javascript"> "use strict";
function CreateRadixTable (){
// Create table heading.
console.log("Hex".padStart(3," ")+
"Dec".padStart(6," ")+"Bin".padStart(9," ")+
"Oct".padStart(6," "))
for (var x = 0; x <= 32; x++) {
var s = "";
// Convert to hexadecimal.
s += (x.toString(16)).padStart(3," ");
// Convert to decimal.
s += (x.toString(10)).padStart(6," ")
// Convert to binary.
s += (x.toString(2)).padStart(9," ")
// Convert to octal.
s += (x.toString(8)).padStart(6," ")
console.log(s);
}
}
CreateRadixTable ();
</script>
Exécution :
Les Strings
-13/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
Hex
0
1
2
3
4
5
6
7
8
9
a
b
c
d
e
f
Dec
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Bin
0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
JavaScript
Oct
0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
10
11
12
13
14
15
16
17
18
19
1a
1b
1c
1d
1e
1f
20
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
10000
10001
10010
10011
10100
10101
10110
10111
11000
11001
11010
11011
11100
11101
11110
11111
100000
20
21
22
23
24
25
26
27
30
31
32
33
34
35
36
37
40
Pour vérifier si une chaîne commence ou se termine par une souis-chaîne
donnée on peut utiliser les méthodes « startsWith() », « endsWith() »,
substr(d , L), substring(d , d+L).
startsWith(), endsWith(), substr(d , L), substring(d , d+L) :
<script type="text/javascript"> "use strict";
console.log("abcde".startsWith("cd",2)) // true
console.log("abcde".endsWith("de")) // true
console.log("abcdef".substr(2,3)=="cde") // true (d, L)
console.log("abcdefg".substring(2,5)=="cde")
// false (d, d+L) ou (d, F-1)
console.log("«"+"abcdefg".substr("b","d")+"»")
// vide
console.log("«"+"abcdefg".substring("b","d")+"»")
// vide
console.log("«"+"abcdefg".substr("c")+"»") // Tout
console.log("«"+"abcdefg".substring("c")+"»") // Tout
Les Strings
-14/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
console.log("«"+"abcdefg".substr()+"»") // Tout
console.log("«"+"abcdefg".substring()+"»") // Tout
</script>
localeCompare , search :
<script type="text/javascript"> "use strict";
console.log("ddd".localeCompare("ddd")) // 0
console.log("ddd".localeCompare("ddc")) // 1
console.log("ddd".localeCompare("dde")) // -1
console.log("ddda".localeCompare("ddd")) // 1
console.log("ddd".localeCompare("ddda")) // -1
console.log("ddd".search("ddd")) // 0
console.log("abcabc".search("ca")) // 2
console.log("ddd".search("ddda")) // -1
console.log("abcabcabc".match("bc")) // Array ["bca"]
console.log("abcabc".match("bcd")) // null
</script>
Les Strings
-15/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
Tester si une chaîne est plus « lourde » qu’une deuxième :
<script type="text/javascript">
var str1 = "ddd";
"use strict";
var str2 = "aaaa"
console.log(str1.localeCompare(str2));
// 1
var str3 = "dd";
console.log(str1.localeCompare(str3));
// 1
var str4 = "ddd";
console.log(str1.localeCompare(str4));
// 0
var str5 = "dddd";
console.log(str1.localeCompare(str5)); /* -1 */
</script>
Truc / Astuce pour trier une chaîne de caractères :
Les Strings
-16/29-
jeudi 4 avril 2019 (10:42:59 PM)
DIASOLUKA Nz. Luyalu
JavaScript
Allons-y étape par étape :
String() . split() sans arguments :
String() . split() avec argument « espace » :
String() . split() avec argument « chaîne vide » :
Les Strings
-17/29-
jeudi 4 avril 2019 (10:42:59 PM)
J.D.B. DIASOLUKA Nz. Luyalu
Différents types d’Arrays
JavaScript Tome-XXII
- 18/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-XXII
VIII. Coder un texte avec « btoa(chaîne binaire) » et le décoder
avec « atob(chaîne base64String) ». Cette technique permet de
transmettre sans faille (interruption intempestive) un texte qui contient des caractères spéciaux entre ASCII 0 et ASCII 31.
<script type="text/javascript"> "use strict";
let stg="Ne confondez pas « types de "+
"données (minuscules) » et "+
"« objets standard » (Capitalisés)";
// Encoder le texte
let encodedData = btoa(stg);
console.log(encodedData);
// Décoder le texte
let decodedData = atob(encodedData);
console.log(decodedData);
// Encoder texte contenant caractères spéciaux
encodedData = btoa(escape(stg));
console.log(encodedData);
// Décoder le texte
decodedData = unescape(atob(encodedData));
console.log(decodedData);
</script>
Pour rechercher une sous-chaîne dans une String on peut utiliser la méthode « indexOf » ou « lastIndexOf ».
<script type = "text/javascript">
var ss = "chasseur";
var str =
"Un chasseur sachant chasser sans son chien est un
bon chasseur";
console.log("str.indexOf(ss) =", str.indexOf(ss));
console.log("str.lastIndexOf(ss =)",
str.lastIndexOf(ss));
</script>
Différents types d’Arrays
- 19/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
str.indexOf(ss) = 3
str.lastIndexOf(ss) = 54
I.
JavaScript Tome-XXII
test.html:5:4
test.html:6:4
Vérifier si une chaîne contient une sous-chaîne donnée :
Quelques méthodes qui le permettent sont :
includes() :
<script type="text/javascript"> "use strict";
console.log("abcde".includes("cd")) // true
console.log("abcde".includes("cd", 2)) // true
console.log("abcde".includes("CD")) // false
console.log("abcde".includes("cd", 3)) // false
console.log("abcabc".indexOf("ca")) // 2
console.log("abcde".indexOf("de")==3) // true
console.log("abcabc".indexOf("x")) // -1
console.log("abcab".indexOf("de")==3) // false
console.log("a.b.c.d".lastIndexOf(".")) // 5
console.log("abcab".lastIndexOf("ab")==3) // true
console.log("abcabc".lastIndexOf("x")) // -1
console.log("abcab".lastIndexOf("de")==-2) // false
</script>
Mais on peut aussi utiliser une expression régulière (RegExp) pour vérifier
si une chaîne contient une sous-chaîne donnée.
RegExp . match ( ) :
<script type = "text/javascript">
const rgi = /chasseur/gi;
var str =
"Un Chasseur sachant chasser sans son chien "+
Différents types d’Arrays - 20/29 - jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-XXII
"est un bon CHASSEUR mieux qu'un autre chasseur";
console.log(str.match(rgi));
const rgCH = /CHASSEUR/g;
var str =
"Un Chasseur sachant chasser sans son chien "+
"est un bon CHASSEUR mieux qu'un autre chasseur";
console.log(str.match(rgCH));
const rgc = /chasseur/g;
var str =
"Un Chasseur sachant chasser sans son chien "+
"est un bon CHASSEUR mieux qu'un autre chasseur";
console.log(str.match(rgc));
const rgC = /Chasseur/g;
var str =
"Un Chasseur sachant chasser sans son chien "+
"est un bon CHASSEUR mieux qu'un autre chasseur";
console.log(str.match(rgC));
const ri = /CHASSEUR/i;
var str =
"Un Chasseur sachant chasser sans son chien "+
"est un bon CHASSEUR mieux qu'un autre chasseur";
console.log(str.match(ri));
</script>
RegExp . search ( ) :
<script type = "text/javascript">
var re = /sans son chien/gi;
var str = "Un chasseur sachant chasser sans son chien est un
bon chasseur";
Différents types d’Arrays
- 21/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-XXII
if ( str.search(re) == -1 ) {
console.log("«",str,"»\nne contient pas «", re,"»");
}
else {
console.log("«",str,"»\nContient «", re,"»");
}
</script>
Exécution :
« Un chasseur sachant chasser sans son chien est un bon
chasseur »
Contient « /sans son chien/gi »
test.html:10:7
« RegExp » est un objet. Voici la structure de la nôtre en cliquant sur l’objet
« RegExp » de l’affichage ci-dessus dans la fenêtre de la console :
« /sans son chien/gi
global: true
ignoreCase: true
lastIndex: 0
multiline: false
source: "sans son chien"
sticky: false
unicode: false
<prototype>: Object { … }
»
<prototype>: {…}
compile: function compile()
constructor: function RegExp()
"$&": "sans son chien"
"$'": " est un bon chasseur"
"$+": ""
"$1": ""
"$2": ""
"$3": ""
"$4": ""
"$5": ""
"$6": ""
Différents types d’Arrays
- 22/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-XXII
"$7": ""
"$8": ""
"$9": ""
"$_": "Un chasseur sachant chasser sans son chien
est un bon chasseur"
"$`": "Un chasseur sachant chasser "
input: "Un chasseur sachant chasser sans son chien
est un bon chasseur"
lastMatch: "sans son chien"
lastParen: ""
leftContext: "Un chasseur sachant chasser "
length: 2
name: "RegExp"
prototype: Object { … }
rightContext: " est un bon chasseur"
Symbol(Symbol.species): Getter
<prototype>: function ()
apply: function apply()
arguments: null
bind: function bind()
call: function call()
caller: null
constructor: function Function()
length: 0
name: ""
toSource: function toSource()
toString: function toString()
Symbol(Symbol.hasInstance):
function Symbol.hasInstance()
<prototype>: Object { … }
exec: function exec()
flags: Getter
global: Getter
ignoreCase: Getter
multiline: Getter
source: Getter
sticky: Getter
test: function test()
toSource: function toString()
toString: function toString()
unicode: Getter
Symbol(Symbol.match): function Symbol.match()
Symbol(Symbol.replace): function Symbol.replace()
Différents types d’Arrays
- 23/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-XXII
Symbol(Symbol.search): function Symbol.search()
Symbol(Symbol.split): function Symbol.split()
<prototype>: Object { … }
__defineGetter__: function __defineGetter__()
__defineSetter__: function __defineSetter__()
__lookupGetter__: function __lookupGetter__()
__lookupSetter__: function __lookupSetter__()
constructor: function Object()
assign: function assign()
create: function create()
defineProperties:
function defineProperties()
defineProperty: function defineProperty()
entries: function entries()
freeze: function freeze()
getOwnPropertyDescriptor:
function getOwnPropertyDescriptor()
getOwnPropertyDescriptors:
function getOwnPropertyDescriptors()
getOwnPropertyNames:
function getOwnPropertyNames()
getOwnPropertySymbols:
function getOwnPropertySymbols()
getPrototypeOf: function getPrototypeOf()
is: function is()
isExtensible: function isExtensible()
isFrozen: function isFrozen()
isSealed: function isSealed()
keys: function keys()
length: 1
name: "Object"
preventExtensions:
function preventExtensions()
prototype: Object { … }
seal: function seal()
setPrototypeOf: function setPrototypeOf()
values: function values()
<prototype>: function ()
hasOwnProperty: function hasOwnProperty()
isPrototypeOf: function isPrototypeOf()
propertyIsEnumerable:
function propertyIsEnumerable()
toLocaleString: function toLocaleString()
Différents types d’Arrays
- 24/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-XXII
toSource: function toSource()
toString: function toString()
valueOf: function valueOf()
Voici la structure d’une « RegExp » telle que nous l’obtenons à la console
quand nous tapons ce mot à la ligne de commande. Nous y voyons toutes
les entrées que nous pouvons exploiter d’un « RegExp » :
Kinshasa, le jeudi, 4. avril 2019 (10:43 ).
Différents types d’Arrays
- 25/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-XXII
Mots-clés :
String, Array, chaînes de caractères, langage C, en JavaScript, imuable, imutable, expression régulière, expressions régulières, RegExp, spread operator,
crochets, TypeCasting, startsWith, endsWith, substr, substring, startsWith,
endsWith, substr, localeCompare, btoa, atob
DIASOLUKA Nz. Luyalu
Docteur en Médecine, Chirurgie & Accouchements (1977),
CNOM : 0866 - Spécialiste en ophtalmologie (1980)
Études humanités : Scientifique - Mathématiques & Physique.
Informaticien-amateur, Programmeur et WebMaster.
Chercheur indépendant, autonome et autofinancé, bénévole, sans
aucun conflit d’intérêt ou liens d'intérêts ou contrainte
promotionnelle avec qui qu’il soit ou quelqu’organisme ou institution
/ organisation que ce soit, étatique, paraétatique ou privé, industriel
ou commercial en relation avec le sujet présenté.
+243 - 851278216 - 899508675 - 991239212 - 902263541 - 813572818
[email protected]
Autre Lecture :
https://www.scribd.com/document/374738470/Le-Plus-Grand-Secret-de-LaCreation
D’autres publications pouvant aussi intéresser :
Différents types d’Arrays
- 26/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-XXII
• https://www.scribd.com/document/377036251/LeDosage-Des-Medicaments-en-Cac-Cas
• https://www.scribd.com/document/377035454/LeHasard-Des-Thermometres-Non-contact-a-Infrarouge
• https://www.scribd.com/document/376222482/PetiteIntroduction-Aux-Fonctions-JavaScript
• https://www.scribd.com/document/376221919/La-Foien-Jesus-Christ-Pour-Quoi-Faire
• https://www.scribd.com/document/375689778/Lacuitevisuelle-angulaire
• https://www.scribd.com/document/375349851/Lavariable-This
•
https://www.scribd.com/document/375024162/FonctionsImbriquees-en-JS
• https://www.scribd.com/document/374789297/FormatInterne-Des-Objets-JavaScript
•
https://www.scribd.com/document/374788758/Iterationsen-JavaScript
• https://www.scribd.com/document/374738470/Le-PlusGrand-Secret-de-La-Creation
• https://www.scribd.com/document/374597969/NouvelleFormule-d-IMC-indice-de-doduite-Selon-Dr-Diasoluka
• https://www.scribd.com/document/373847209/PropertyDescriptors
• https://www.scribd.com/document/373833282/l-ObjetGlobal-Window
•
Différents types d’Arrays
- 27/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-XXII
https://www.scribd.com/document/372665249/JavascriptTome-II
• https://www.scribd.com/document/355291488/motiliteoculaire-2
• https://www.scribd.com/document/355291239/motiliteoculaire-I
• https://www.scribd.com/document/355290248/Script-dAnalyses-Des-Reflexes-Pupillomoteurs
•
https://www.scribd.com/document/321168468/Renseigne
ments-Id-et-Anthropometriques
•
https://www.scribd.com/document/320856721/Emission31-Jul-2016
•
https://www.scribd.com/document/318182982/Complicati
on-Visuelle-du-Traitement-de-La-Malaria
• https://www.scribd.com/document/318180637/RapportEntre-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-deLaboratoire
• https://www.scribd.com/document/315745725/RapportEntre-Oxymetrie-Et-Type-Respiration
Différents types d’Arrays
- 28/29 -
jeudi, 4. avril 2019 (10:43 )
J.D.B. DIASOLUKA Nz. Luyalu
Différents types d’Arrays
JavaScript Tome-XXII
- 29/29 -
jeudi, 4. avril 2019 (10:43 )