**********************Object Literal Notation*************************
let firstObject = {};
[Link]('firstObject',firstObject);
let secondObject = {id : 177, name : 'Jane', age : 25};
[Link]('secondObject',secondObject);
The properties present inside the literal object can be accessed by using either a
dot notation or a bracket notation.
[Link]('Dot Notation',[Link]);
[Link]('Bracket Notation',secondObject.['name']);
[Link] = 188;
[Link]('New Id',[Link]);
//Before ES6
let name = 'john';
let age = 42;
let empObj = {
empname : name;
empage : age
}
[Link]('EmpObj',empObj);
//With ES6
let empObjes6 = {
name,
age
}
[Link]('newES6style',empObjes6);
To access the values present in literal object, use the [Link]() method.
[Link]('Values of secondObject',[Link](secondObject));
**********************Class & Static Keyword*************************
class Employee {
constructor(empId,empName,empAge){
[Link] = empId;
[Link] = empName;
[Link] = empAge;
}
swipeIn(){
[Link]('Employee Id',[Link],' has swiped in at '), new
Date().toLocaleDateString());
static code(){
[Link]('Employee is coding');
}
}
}
let empObj = new Employee(100,"Mark",23);
[Link]('Id ', [Link]);
[Link]('Name ', empObj['id']);
JavaScript classes can also have static methods.
Static methods can be created using static keyword.
[Link]();
Create objects using the class keyword.
Declare methods and create properties in this class.
How to access these properties using dot operator or square brackets.
***************************Inheritance******************************
class PartTimeEmployee extends Employee {
constructor(empid,empname,contractPeriod){
super(empid,empname);
[Link]=contractPeriod;
}
swipeIn(){
[Link](' Contract Employee Swiped In');
[Link]();
}
}
let empChild = new PartTimeEmployee(787,"Jane",3);
[Link]();
[Link]();
[Link]();