function personne(nom,prenom){ this.nom=nom ; this.prenom=prenom ; }
personne.prototype.presenter=function(){ return "je m'appel" + this.nom + " " + this.prenom ; }
personne.collection=new Array() personne.add=function(p){ If(typeof p =="personne"){ Personne.collection.push(p) ; } }
var p1=new personne("DUPONT","Pierre"); var p2=new personne("DUPOND","Jean"); personne.add(p1); personnne.add(p2); for(i=0;i<personne.collection.length;i++){ personne.collection[i].presenter(); }
prototype.isMail=function(){ var reg=new RegExp(“^(\{1,12})@([a-z * {1,15}\.([a-z]{1,3})$”, “ i”) ; return reg.test(this) ; }
console.log([mailto:monmail@voila.fr monmail@voila.fr]".isMail());
console.log(monmail@bobi".isMail());
prototype.getMatch=function(reg){ //définir le type de reg Switch(typeof reg){ Case "string" : { //la variable reg est une chaîne de caractère, //nous allons créer un nouveau RegExp var r=new RegExp(reg, [" i" * ) ; return r.exec(this)//on retourne le tableau break ; } Case "object" : { //la variable reg est un objet (donc une RegExp) If(reg.exec)//On test si l'objet possède notre méthode return reg.exec(this) ; //on retourne le tableau else throw "not a regexp" break ; } } }
console.dir("mon nom est DUPONT".matches("mon nom est ((?:[a-z * [a-z0-9_]*))") ; console.dir("mon nom est DUPONT".matches(new RegExp("mon nom est ((?:[a-z * [a-z0-9_]*))",["i" ])) ;
0 | "mon nom est DUPONT" |
1 | DUPONT |
index | 0 |
input | "mon nom est DUPONT" |
prototype.valueOf=function(a){ var b=false ; var i=0 ; while(i){ if(a[i] == this){ b=true ; } else{ i++ ; } } return b ; }
console.log("banane".valueOf(["Framboise","banane","Fraise","kiwi"] ) ;
Avis de décès, Carte de voeux, Bricolage, Coloriages, Cinéma, Coiffure, Cuisine, Déco, Dictionnaire, Horoscope, Jeux en ligne, Programme TV, Recettes, Restaurant, SMIC, Test débit, Voyage, Signification prénom