Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to invoke a function in a class

class Wizard{
  constructor(name, age, favoriteSpell){
    this.name = name;
    this.age = age;
    this.favoriteSpell = favoriteSpell;
  }
  // function that is being envoked
  castSpell() {
    console.log(`${this.name} has cast ${this.favoriteSpell}`)
  }
}

let gandolf = new Wizard('gandolf', 998, '')
gandolf.castSpell()
Comment

PREVIOUS NEXT
Code Example
Javascript :: scan token deploy js 
Javascript :: when end sound show alert 
Javascript :: chai promise resolved 
Javascript :: Expresion regular para validar contraseñas 
Javascript :: Total amount of points 
Javascript :: declare 2 d vector js 
Javascript :: find numeric Unicode value of the character with charCodeAt() method 
Javascript :: rxact 6 number long in yup validation 
Javascript :: Return characters in a string in alphabetic order 
Javascript :: Assign A New Method To Every Node 
Javascript :: convert javascript to python 
Javascript :: js convert string to number 
Javascript :: convert json to csv npm 
Javascript :: react router browser refresh 
Javascript :: sort array method 
Javascript :: what is local storage and session storage in javascript 
Javascript :: destructuring in javascript 
Javascript :: Javascript count instances of character in a string 
Javascript :: pass infinite argument in function 
Javascript :: getDownload url in firebase 
Javascript :: spread operator es6 
Javascript :: react portal example 
Javascript :: how to access value of itself object in javascript 
Javascript :: scrollbar position 
Javascript :: hide checkbox jquery 
Javascript :: react -native-config 
Javascript :: get sessionstorage value in jquery 
Javascript :: react-validex 
Javascript :: i get two times event click of button javascript 
Javascript :: javascript dom methods list 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =