JavaScript
What is JavaScript ?
JavaScript is a cross-platform, object-oriented scripting language used mainly for enhancing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript( having animations, clickable buttons, popup menus, etc.).
Some js Characteristics :
- Object-Centered Script Language
- Client edge Technology
- Validation of User’s Input
- Else and If Statement
- Interpreter Centered
- Ability to perform In Built Function
- Case Sensitive format
- Light Weight and delicate
- Statements Looping
- Handling Events
Basic Operators of JS
- +— Addition
- -— Subtraction
- *— Multiplication
- / — Division
- (…) — Grouping operator, operations within brackets are executed earlier than those outside
- % — Modulus (remainder )
- ++ — Increment numbers
- – — Decrement numbers
let’s find out some Data Types of JS and
- Numbers —> var age = 23
- Variables —> var x
- Text (strings) —> var a = “init”
- Operations —> var b = 1 + 2 + 3
- True or false statements —> var c = true
- Constant numbers —> const PI = 3.14
Comparison Operators
Operator | Description | Example |
---|---|---|
(==) | Equal to: true if the operands are equal | 5==5; //true |
(!=) | Not equal to: true if the operands are not equal | 5!=5; //false |
(===) | Strict equal to: true if the operands are equal and of the same type | 5===’5’; //false |
(!==) | Strict not equal to: true if the operands are equal but of different type or not equal at all | 5!==’5’; //true |
(>) | Greater than: true if the left operand is greater than the right operand 3>2; //true | |
(>=) | Greater than or equal to: true if the left operand is greater than or equal to the right operand | 3>=3; //true |
(<) | Less than: true if the left operand is less than the right operand | 3<2; //false |
(<=) | Less than or equal to: true if the left operand is less than or equal to the right operand | 2<=2; //true |
Loops: while and for
- for Loops Syntax:
- for(statement1; statement2; statment3)
- {
- lines of code to be executed
- }
- while Loops Syntax
- while(condition)
- {
- lines of code to be executed
- }