21x51a0544 CRUD, Operators, Data-Types
21x51a0544 CRUD, Operators, Data-Types
ASSIGNMENT-2
create, read, update, delete
create, read”
<script>
let college={
name:"srec",
address:"ndl",
rating:5
};
console.log(college);
console.log(college.name);
</script>
Update:
<script>
let college={
name:"srec",
name:"rgm",
address:"ndl",
rating:5
};
console.log(college);
console.log(college.name);
</script>
Delete:
<script>
let college={
name:"srec",
name:"rgm",
address:"ndl",
rating:5
};
delete college.address
console.log(college);
console.log(college.name);
</script>
Assignment-3
Operators in js
1) Assignment operators: =
2) Arithmetic operators: + - * / %
3) Short hand math: +=, /==, *=, -=
4) Conditional operators: <, >, <=, >=, ! ==
5) Unary operators: ++, --
6) Logical: &&, ||, ^ (ex-or operator)
7) Ternary operators: ?:
8) Equity opeartors: ==, ===
1) Assignment Operators
= (Assignment)
+= (Addition assignment)
-= (Subtraction assignment)
*= (Multiplication assignment)
/= (Division assignment)
%= (Modulus assignment)
**= (Exponentiation assignment)
2) Arithmetic Operators
+ (Addition)
- (Subtraction)
* (Multiplication)
/ (Division)
% (Modulus)
** (Exponentiation)
3) Short hand math
Addition
x += y is equivalent to x = x + y
Subtraction
x -= y is equivalent to x = x - y
Multiplication
x *= y is equivalent to x = x * y
Division
x /= y is equivalent to x = x / y
Modulus
x %= y is equivalent to x = x % y
Exponentiation
x **= y is equivalent to x = x ** y
let x = 5;
x += 3;-----equivalent to x = x + 3
console.log(x); output: 8
4)Conditional operators
== (Equal to)
!= (Not equal to)
> (Greater than)
< (Less than)
>= (Greater than or equal to)
<= (Less than or equal to)
5) Unary operators
+ (Unary plus)
- (Unary negation)
! (Logical NOT)
~ (Bitwise
NOT) typeof
(Typeof) void
(Void)
6) Logical Operators
&& (And)
|| (Or)
! (Not)
7) Ternary Operator
?: (Conditional)
condition ? expressionIfTrue : expressionIfFalse;
condition: A boolean expression that evaluates to true or false.
expressionIfTrue: The value to return if the condition is true.
expressionIfFalse: The value to return if the condition is false.
Example:
let age = 25;
let status = age >= 18 ? 'adult' : 'minor';
In this example:
age >= 18 is the condition.
'adult' is the expression to return if the condition is true.
'minor' is the expression to return if the condition is false.
8) Equity operators
In JavaScript, equality operators are used to compare values and
determine if they are equal or not. Here are the equality operators
in JavaScript:
=== (Strict Equality)
Checks if the values and data types are equal.
Example: 5 === 5 returns true, 5 === '5' returns false
!== (Strict Inequality)
Checks if the values or data types are not equal.
Example: 5 !== 5 returns false, 5 !== '5' returns true
== (Loose Equality)
Checks if the values are equal, but ignores data type differences.
Example: 5 == 5 returns true, 5 == '5' returns true
!= (Loose Inequality)
Checks if the values are not equal, ignoring data type differences.
Example: 5 != 5 returns false, 5 != '5' returns false