Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

create method javascript

//Method is indicated by *
//Constructor Function
function BellBoy (name, age, hasWorkPermit, languages) {
  this.name = name;
  this.age = age;
  this.hasWorkPermit = hasWorkPermit;
  this.languages = languages;
  this.pickUpSuitcase = function() {//*object associated function (method) 
    console.log('suitcase is picked up')
  }
  this.move = function() {//*object associated function (method)
    console.log(`${this.name} is on the move`)
  }
  this.moveSuitcase = function() {//*object associated function (method)
    alert("May I take your suticase?");
      this.pickUpSuitcase(); this.move();
  } 
}

//Create New Object From Constructor Using Arguments
var bellBoy1 = new BellBoy('Earl E.Bird', 23, true, ['French', 'German'])

//Access the Properties and Their Values
console.log('Name : ', bellBoy1.name)
console.log('Age : ', bellBoy1.age)
console.log('Verified Work Permit : ', bellBoy1.hasWorkPermit)
console.log('Languages : ', bellBoy1.languages)

//calling the method
bellBoy1.moveSuitcase();
Comment

PREVIOUS NEXT
Code Example
Javascript :: node fetch 
Javascript :: var in js 
Javascript :: moment duratuion from hours 
Javascript :: events onclick 
Javascript :: try catch javascript 
Javascript :: modal slide from right 
Javascript :: js add zeros before number 
Javascript :: private route in react js 
Javascript :: check if string Array javascript 
Javascript :: how to export fs.readFile 
Javascript :: creating a json 
Javascript :: jquery get name value method 
Javascript :: react native pure component vs component 
Javascript :: how to get data from for loop in react native 
Javascript :: flatlist inside flatlist react native 
Javascript :: find element causing vertical overflow 
Javascript :: ready function jq 
Javascript :: The .querySelector() Method 
Javascript :: what is closure in javascript 
Javascript :: Different views for Desktop and mobile Angular 
Javascript :: Fill rect in jspdf 
Javascript :: javascript remove last element 
Javascript :: angular form validation whitespace 
Javascript :: rad client datasource refetch 
Javascript :: angular 11 export excel with customize header 
Javascript :: button remove class jquery 
Javascript :: shorthand if in javascript with return 
Javascript :: ReactDOM render in v18 
Javascript :: how to join kak in javascript 
Javascript :: modal react form table 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =