new instance of object javascript
class Person {
constructor(fname, lname) {
this.firstName = fname;
this.lastName = lname;
}
}
const person = new Person('testFirstName', 'testLastName');
console.log(person.firstName); // testFirstName
console.log(person.lastName); // testLastName
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
var car1 = new Car('Eagle', 'Talon TSi', 1993);
console.log(car1.make);
// expected output: "Eagle"
Also in JavaScript:
- react native function
- push values to state array class react
- javascript explode space
- A form label must be associated with a control react
- ajax is not a function
- how to add data-toggle and data-target using jquery
- javascript open url
- review rating design
- event when variable value changes javascript
- how to receive window.postmessage event in angular 9
- inject firebase in angularjs
- delete backspace on string js
- flatten array object javascript
- layer on top in javascript
- how to get css property of div after rendering in react js
- javascript object read only
- import checkbox material ui
- set cookie in node
- replace innerhtml javascript by regex
- javascript import
- close bootstrap modal with javascript
- create csv file nodejs
- implement subscript operator js
- how to find date in a string js