Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

ES6: Use class Syntax to Define a Constructor Function

class Vegetable {
  constructor(name) {
    this.name = name;
  }
}
const carrot = new Vegetable('carrot');
Comment

Declare Function In Class Constructor

	class Person
	 {
	 	
	constructor(name)
		 {
			 this.name = name;
			
		 

const xxx = async ()=>
		 {
		 	
			 alert("XXXXX");		
			
		 }	
	 
		 xxx();
	 
	 }
	 }
Comment

class function constructor

class country{
  constructor(name, independenceOn){

  this.name = name
  this.independenceOn = independenceOn
}
  describe = function () {
    console.log(this.name + " got its independence on " + this.independenceOn + " WHAHAHAHAH")
  }
}

const india = new country('The Country India', 1947)
india.describe()
Comment

PREVIOUS NEXT
Code Example
Javascript :: currentContract.transferFrom is not a function 
Javascript :: array loop 
Javascript :: Backbon events In View 
Javascript :: what is renderer in three.js 
Javascript :: Ghost-Blog MySQL install was not found 
Javascript :: RTC measure react native undefined 
Javascript :: How to switch to a remote git branch that does not exist locally 
Javascript :: redwood toaster 
Javascript :: owl get parent state 
Javascript :: I want to filter the below json data by start date and end date, it should return the data between start date and end date, 
Javascript :: find parent index of nested array object javascript 
Javascript :: nodejs express parse query params boolean 
Javascript :: class parent and class child 
Javascript :: Creatable Multiselect 
Javascript :: allow only numbers in textbox javascript onkeypress 
Javascript :: Can Execute Backbone In RequireJS 
Javascript :: React PrivateRoute componenet 
Javascript :: telerik grid destroy table 
Javascript :: save input local storage react 
Javascript :: hide Card Number Format 
Javascript :: React clock via props 
Javascript :: jquery questions and answers 
Javascript :: oop js 
Javascript :: array reverse 
Javascript :: shell curl path of json file as parameter without temporal file 
Javascript :: set timeout with no name 
Javascript :: angular date passed to donet care is a day less 
Javascript :: pass a callback funcion into an async function node js 
Javascript :: angular resolver with parameters 
Javascript :: laravel onkeyup textbox, get value from span javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =