Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

POO js

function creerNouvellePersonne(nom) {
  var obj = {};
  obj.nom = nom;
  obj.salutation = function() {
    alert('Salut ! Je m'appelle ' + this.nom + '.');
  };
  return obj;
}
Comment

POO js

function Personne(nom) {
  this.nom = nom;
  this.salutation = function() {
    alert('Bonjour ! Je m'appelle ' + this.nom + '.');
  };
}
Comment

POO js

var personne1 = new Personne('Bob');
var personne2 = new Personne('Sarah');
Comment

POO js

personne1.nom
personne1.salutation()
personne2.nom
personne2.salutation()
Comment

PREVIOUS NEXT
Code Example
Javascript :: js capitalize first letter of each word 
Javascript :: node js return ID in postgres insert 
Javascript :: create angular project 
Javascript :: convert an array to string javascript 
Javascript :: concat js mdn 
Javascript :: javascript indexof with condition 
Javascript :: check user by id discord js 
Javascript :: javascript change font color based on value 
Javascript :: npm error Could not resolve dependency peer react@"^18.0.0" from react-test-renderer@18.0.0 
Javascript :: counts the duplicates in an array using for loop 
Javascript :: suppress spaces in front and in the end of a string javascript 
Javascript :: input focus in jquery 
Javascript :: jest input value 
Javascript :: todashcase javascript 
Javascript :: get date in specific timezone 
Javascript :: how to save and use item from local storage javascript 
Javascript :: move canvas element to mouse 
Javascript :: joi unique validation 
Javascript :: socket.io client send data node js server 
Javascript :: javascript remove duplicates 
Javascript :: javascript random number up to including 2 
Javascript :: express router file 
Javascript :: js filter out doubles 
Javascript :: is function javascript 
Javascript :: date get full year 
Javascript :: how to play sound on load js 
Javascript :: momentjs format date 
Javascript :: starting express server 
Javascript :: tailwind content for nextjs 
Javascript :: repeat an element in array in js 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =