JavaScript Syntax
💎JavaScript syntax is the set of rules, how JavaScript programs are constructed:
📌JavaScript Values
The JavaScript syntax defines two types of values:
💎Fixed values are called Literals.
JavaScript Literals
The two most important syntax rules for fixed values are:
1. Numbers are written with or without decimals:
2. Strings are text, written within double or single quotes:
💎Variable values are called Variables.
In a programming language, variables are used to store data values.
JavaScript uses the var keyword to declare variables.
An equal sign is used to assign values to variables.
@javascript_tut
"w3schools .com"
💎JavaScript syntax is the set of rules, how JavaScript programs are constructed:
📌JavaScript Values
The JavaScript syntax defines two types of values:
💎Fixed values are called Literals.
JavaScript Literals
The two most important syntax rules for fixed values are:
1. Numbers are written with or without decimals:
2. Strings are text, written within double or single quotes:
💎Variable values are called Variables.
In a programming language, variables are used to store data values.
JavaScript uses the var keyword to declare variables.
An equal sign is used to assign values to variables.
@javascript_tut
"w3schools .com"
JavaScript Operators
JavaScript uses arithmetic operators ( + - * / ) to compute values:
JavaScript uses an assignment operator ( = ) to assign values to variables:
@javascript_tut
"w3schools .com"
JavaScript uses arithmetic operators ( + - * / ) to compute values:
JavaScript uses an assignment operator ( = ) to assign values to variables:
@javascript_tut
"w3schools .com"
📌JavaScript Classes
💎ECMAScript 2015, also known as ES6, introduced JavaScript Classes.
💎JavaScript Classes are templates for JavaScript Objects.
📌JavaScript Class Syntax
💎Use the keyword class to create a class.
💎Always add a method named constructor():
--------------------------------------------
The example above creates a class named "Car".
The class has two initial properties: "name" and "year".
--------------------------------------------
🔑A JavaScript class is not an object.
🔑It is a template for JavaScript objects.
@javascript_tut
"w3schools .com"
💎ECMAScript 2015, also known as ES6, introduced JavaScript Classes.
💎JavaScript Classes are templates for JavaScript Objects.
📌JavaScript Class Syntax
💎Use the keyword class to create a class.
💎Always add a method named constructor():
--------------------------------------------
The example above creates a class named "Car".
The class has two initial properties: "name" and "year".
--------------------------------------------
🔑A JavaScript class is not an object.
🔑It is a template for JavaScript objects.
@javascript_tut
"w3schools .com"
📌Using a Class
💎When you have a class, you can use the class to create objects:
The example above uses the Car class to create two Car objects.
💎The example above uses the Car class to create two Car objects.
----------------------------------------
The example above uses the Car class to create two Car objects.
---------------------------------------
🔑The constructor method is called automatically when a new object is created.
@javascript_tut
"w3schools .com"
💎When you have a class, you can use the class to create objects:
The example above uses the Car class to create two Car objects.
💎The example above uses the Car class to create two Car objects.
----------------------------------------
The example above uses the Car class to create two Car objects.
---------------------------------------
🔑The constructor method is called automatically when a new object is created.
@javascript_tut
"w3schools .com"
📌The Constructor Method
💎The constructor method is a special method:
👉It has to have the exact name "constructor"
👉It is executed automatically when a new object is created
👉 It is used to initialize object properties
🔑If you do not define a constructor method, JavaScript will add an empty constructor method.
@javascript_tut
"w3schools .com"
💎The constructor method is a special method:
👉It has to have the exact name "constructor"
👉It is executed automatically when a new object is created
👉 It is used to initialize object properties
🔑If you do not define a constructor method, JavaScript will add an empty constructor method.
@javascript_tut
"w3schools .com"
📌Class Methods
💎Class methods are created with the same syntax as object methods.
💎Use the keyword class to create a class.
💎Always add a constructor() method.
💎Then add any number of methods.
@javascript_tut
"w3schools .com"
💎Class methods are created with the same syntax as object methods.
💎Use the keyword class to create a class.
💎Always add a constructor() method.
💎Then add any number of methods.
@javascript_tut
"w3schools .com"
📌Class extends
💎The extends keyword is used to create a child class of another class (parent).
💎The child class inherits all the methods from another class.
🔑Inheritance is useful for code reusability: reuse properties and methods of an existing class when you create a new class.
📎Note: From the example above; The super() method refers to the parent class. By calling the super() method in the constructor method, we call the parent's constructor method and gets access to the parent's properties and methods.
@javascript_tut
"w3schools .com"
💎The extends keyword is used to create a child class of another class (parent).
💎The child class inherits all the methods from another class.
🔑Inheritance is useful for code reusability: reuse properties and methods of an existing class when you create a new class.
📎Note: From the example above; The super() method refers to the parent class. By calling the super() method in the constructor method, we call the parent's constructor method and gets access to the parent's properties and methods.
@javascript_tut
"w3schools .com"
📌Static Keyword
💎The static keyword defines static methods for classes.
💎Static methods are called directly on the class (Car from the example above) - without creating an instance/object (mycar) of the class.
@javascript_tut
"w3schools .com"
💎The static keyword defines static methods for classes.
💎Static methods are called directly on the class (Car from the example above) - without creating an instance/object (mycar) of the class.
@javascript_tut
"w3schools .com"
Mongodb, Expressjs, Reactjs and Nodejs
MEAN is a free and open-source JavaScript software stack for building dynamic web sites and web applications.
https://t.me/mern_stack_tut
MEAN is a free and open-source JavaScript software stack for building dynamic web sites and web applications.
https://t.me/mern_stack_tut
Telegram
MERN Stack ✅
Mongodb, Expressjs, Reactjs and Nodejs
MEAN is a free and open-source JavaScript software stack for building dynamic web sites and web applications.
MEAN is a free and open-source JavaScript software stack for building dynamic web sites and web applications.