Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js class method called when page loads

// The cnstructor Method runs when you call a class method
// So for example
class App () {
  constructor() {}
  logHello() {
  	console.log("Hello World");
  }
}

const test = new App();
// Immediately you have an instance of that class The constructor
// method is called, so if you want the logHello to log immediately then you can
// call it in the constructor like this

class App () {
  constructor() {
  	this.logHello();
  }
  logHello() {
  	console.log("Hello World");
  }
}

/* This will work on page load because any code not inisde a function or anything
runs on page load */

// Hope you understand and it helps
Comment

PREVIOUS NEXT
Code Example
Javascript :: unpacking array javascript 
Javascript :: object notation and array notation dynamic class binding vuejs 
Javascript :: how to get the contract address from the contract instance web3js 
Javascript :: messageReactionAdd 
Javascript :: animationframe javascript 
Javascript :: capture image from video element 
Javascript :: javascript map return array with distinc values 
Javascript :: how disabled react-select 
Javascript :: js loop through object 
Javascript :: es6 js slug from string 
Javascript :: handle esc press js 
Javascript :: how to change the font family using jquery 
Javascript :: vue router push 
Javascript :: ipv4 to int32 js 
Javascript :: image on press 
Javascript :: how to select data attribute in javascript using queryselectorAll 
Javascript :: js regex between two words 
Javascript :: javascript split array into chunks of 
Javascript :: jquery get top position of element on scroll 
Javascript :: ctx.filltext font size 
Javascript :: how to insert html in javascript 
Javascript :: japan 
Javascript :: jquery einbinden in js 
Javascript :: ajax run function after page load 
Javascript :: jquery selected label option 
Javascript :: loopback model properties 
Javascript :: how to create a random 2d vector in js 
Javascript :: remover clase jquery 
Javascript :: turn number into array javascript 
Javascript :: javascript prompt for download location 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =