class javascript
JavaScript
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
present = () => { //or present(){
console.log(`Hi! i'm ${this.name} and i'm ${this.age} years old`)
}
}
let me = new Person("tsuy", 15);
me.present();
// -> Hi! i'm tsuy and i'm 15 years old.let Person = class {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
}class ClassMates{
constructor(name,age){
this.name=name;
this.age=age;
}
displayInfo(){
return this.name + "is " + this.age + " years old!";
}
}
let classmate = new ClassMates("Mike Will",15);
classmate.displayInfo(); // result: Mike Will is 15 years old!class Car {
constructor(brand) {
this.carname = brand;
}
}class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
// Getter
get area() {
return this.calcArea();
}
// Method
calcArea() {
return this.height * this.width;
}
}
const square = new Rectangle(10, 10);
console.log(square.area); // 100class Car {
constructor(brand) {
this.carname = brand;
}
present() {
return "I have a " + this.carname;
}
}
mycar = new Car("Ford");
document.getElementById("demo").innerHTML
= mycar.present();
Also in JavaScript:
- Title
- how to add validator to formgroup
- Category
- JavaScript
- Title
- how to version a react app azure pipelines
- Category
- JavaScript
- Title
- float to currency js
- Category
- JavaScript
- Title
- clone javascript object
- Category
- JavaScript
- Title
- how to use aos in react
- Category
- JavaScript
- Title
- angular routing url params
- Category
- JavaScript
- Title
- how to make a text editor in html
- Category
- JavaScript
- Title
- fetch get data js
- Category
- JavaScript
- Title
- angular trigger input change
- Category
- JavaScript
- Title
- bootstrap modal remove gray background
- Category
- JavaScript
- Title
- how to create request body javascript
- Category
- JavaScript
- Title
- how to attach javascript to html
- Category
- JavaScript
- Title
- add val to array jquery
- Category
- JavaScript
- Title
- how to build a string javascript es6
- Category
- JavaScript
- Title
- how to check string uppercase or lowersace using regex javascript
- Category
- JavaScript
- Title
- add month date now javascript
- Category
- JavaScript
- Title
- access angular app outside localhost
- Category
- JavaScript
- Title
- how to loop object javascript
- Category
- JavaScript
- Title
- arrays javascript
- Category
- JavaScript
- Title
- event.persist()
- Category
- JavaScript
- Title
- creating a 2d array in js
- Category
- JavaScript
- Title
- boucle for of javascript
- Category
- JavaScript
- Title
- count number of times an element is occuring in an array in javascript
- Category
- JavaScript
- Title
- how to get a value into a react component
- Category
- JavaScript
- Title
- curl post file json
- Category
- JavaScript
- Title
- add to json object javascript
- Category
- JavaScript
- Title
- declare multiple variables javascript
- Category
- JavaScript
- Title
- chrome extension get current tab from popup
- Category
- JavaScript
- Title
- discord.js
- Category
- JavaScript
- Title
- get query string javascript nodejs
- Category
- JavaScript
- Title
- how to make a deep copy in javascript
- Category
- JavaScript
- Title
- dotnet core ajax post of an ojject site:stackoverflow.com
- Category
- JavaScript
- Title
- how to make fake binary
- Category
- JavaScript
- Title
- how to get the end of an array javascript
- Category
- JavaScript
- Title
- javascript array pop
- Category
- JavaScript
- Title
- firebase cheat sheet
- Category
- JavaScript
- Title
- how to get the size of the window in javascript
- Category
- JavaScript
- Title
- how to get the index of an array in javascript
- Category
- JavaScript
- Title
- how to add javascript in html
- Category
- JavaScript
- Title
- code to launch browser using javascript
- Category
- JavaScript
- Title
- electron jquery
- Category
- JavaScript
- Title
- how to use react memo hooks
- Category
- JavaScript
- Title
- how to program an array in js
- Category
- JavaScript
- Title
- Cannot find module '.json'
- Category
- JavaScript
- Title
- how to access all images in a document javascript
- Category
- JavaScript
- Title
- change p tag text javascript
- Category
- JavaScript
- Title
- how to use style in react js
- Category
- JavaScript
- Title
- how to make a random number guessing game in javascript
- Category
- JavaScript
- Title
- elasticsearch test node.js
- Category
- JavaScript
- Title
- how to get data from localstorage in javascript
- Category
- JavaScript
- Title
- default props react
- Category
- JavaScript
- Title
- ionic (Emitted value instead of an instance of Error
- Category
- JavaScript
- Title
- iterate through array javascript
- Category
- JavaScript
- Title
- iterate through list javascript
- Category
- JavaScript
- Title
- gitignore for angular
- Category
- JavaScript
- Title
- bash parse json
- Category
- JavaScript
- Title
- how to write in js
- Category
- JavaScript
- Title
- indexing string in javascript
- Category
- JavaScript
- Title
- fetch post js
- Category
- JavaScript
- Title
- google maps api javascript
- Category
- JavaScript
- Title
- assign values to a table from javascript in VF page
- Category
- JavaScript
- Title
- .change() in pure js
- Category
- JavaScript
- Title
- how to write img jsx
- Category
- JavaScript
- Title
- angular onchange event
- Category
- JavaScript
- Title
- express js sample project
- Category
- JavaScript
- Title
- javascript exercism.io bob solution
- Category
- JavaScript
- Title
- how to know if a number has a decimal number js
- Category
- JavaScript
- Title
- empty a select input using js
- Category
- JavaScript
- Title
- axios post with header
- Category
- JavaScript
- Title
- foreach w3schools javascript
- Category
- JavaScript
- Title
- A cookie associated with a cross-site resource at http://placeholder.com/ was set without the `SameSite` attribute.
- Category
- JavaScript
- Title
- buble sort in js
- Category
- JavaScript
- Title
- iis express gzip
- Category
- JavaScript
- Title
- dataset js
- Category
- JavaScript
- Title
- how to convert array to uppercase in javascript
- Category
- JavaScript
- Title
- Angular watching for changes in $http.pendingRequests from directive
- Category
- JavaScript
- Title
- how to split two digit number in javascript
- Category
- JavaScript
- Title
- jason rpc reactjs
- Category
- JavaScript
- Title
- angular event scroll end of page
- Category
- JavaScript
- Title
- how to get user ip address in javascript
- Category
- JavaScript
- Title
- angular 6 key value pair getvalue example
- Category
- JavaScript
- Title
- clear input field javascript
- Category
- JavaScript
- Title
- javascript change meta tag
- Category
- JavaScript
- Title
- javascript base64 encode
- Category
- JavaScript
- Title
- export apk react native
- Category
- JavaScript
- Title
- Can't bind to 'formGroup' since it isn't a known property of 'form'
- Category
- JavaScript
- Title
- javascript anagram check
- Category
- JavaScript
- Title
- get the size of the screen javascript
- Category
- JavaScript
- Title
- how to run different node app on server different domains
- Category
- JavaScript
- Title
- comparing arrays javascript
- Category
- JavaScript
- Title
- get value javascript
- Category
- JavaScript
- Title
- how to add variable to local storage in javascript
- Category
- JavaScript
- Title
- interceptor in angular 8
- Category
- JavaScript
- Title
- input set variable angular
- Category
- JavaScript
- Title
- generate thumbnail of pdf using pf js
- Category
- JavaScript
- Title
- create dice game javascript
- Category
- JavaScript
- Title
- how to get the value in a tag in react
- Category
- JavaScript
- Title
- getFullYear within moment in angular
- Category
- JavaScript
- Title
- Javascript compare two objects
- Category
- JavaScript
- Title
- dynsmic calss in react add
- Category
- JavaScript