JavaScript Operators

Operators in JavaScript are symbols used to perform operations on variables and values. They are essential for writing logic, calculations, and conditions

1. Arithmetic Operators

Used for mathematical calculations.

OperatorDescriptionExample
+Addition5 + 2 = 7
-Subtraction5 - 2 = 3
*Multiplication5 * 2 = 10
/Division10 / 2 = 5
%Modulus (remainder)5 % 2 = 1
**Exponentiation2 ** 3 = 8

Example:

let a = 10;
let b = 3;console.log(a + b); // 13
console.log(a % b); // 1

2. Assignment Operators

Used to assign values to variables.

OperatorExampleMeaning
=x = 5Assign 5
+=x += 3x = x + 3
-=x -= 2x = x – 2
*=x *= 2x = x * 2
/=x /= 2x = x / 2

Example:

let x = 5;
x += 3; // 8

3. Comparison Operators

Used to compare two values (returns true/false).

OperatorDescription
==Equal (value only)
===Strict equal (value + type)
!=Not equal
!==Strict not equal
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal

Example:

console.log(5 == "5");   // true
console.log(5 === "5"); // false

4. Logical Operators

Used to combine conditions.

OperatorDescription
&&AND
`
!NOT

Example:

let age = 20;if (age > 18 && age < 30) {
console.log("Young adult");
}

5. Unary Operators

Operate on a single operand.

OperatorDescription
++Increment
--Decrement
typeofReturns type
!Logical NOT

Example:

let num = 5;
num++; // 6console.log(typeof num); // number

6. Ternary Operator

Short form of if-else.

Syntax:

condition ? value1 : value2;

Example:

let age = 18;
let result = age >= 18 ? "Adult" : "Minor";

7. Special Operators

Some useful additional operators:

OperatorDescription
?.Optional chaining
??Nullish coalescing
inCheck the property in the object
instanceofCheck object type

Example:

let user = {};
console.log(user?.name); // undefined (no error)let value = null ?? "default";
console.log(value); // "default"

✅ Summary

  • Arithmetic → calculations
  • Assignment → assign values
  • Comparison → compare values
  • Logical → combine conditions
  • Ternary → short if-else
  • Special → modern JS features

✎ Practise what you learned: 32 JavaScript operators programs with solutions →

JavaScript Variables

What Are Variables in JavaScript?

In JavaScript, variables are declared using var, let, and const. These keywords define how variables behave in terms of scope and mutability. Modern JavaScript development strongly favors let and const because they provide better control and reduce unexpected bugs. If you’re building dynamic websites or applications, understanding variables is absolutely essential because they drive logic, interactivity, and data handling.

Why Variables Matter in Programming

Variables allow your program to process user input, perform calculations, and manage application state. Think of them as the memory of your application. Without variables, even simple tasks like storing a username or calculating a total price would be impossible.

Real-Life Analogy for Variables

Consider a backpack you carry every day. You can put books, gadgets, or food inside it. Some items you replace frequently, while others stay the same. That’s exactly how variables behave depending on how you declare them.


Types of Variable Declarations

Understanding var

The var The keyword is the oldest method for declaring variables in JavaScript. It is function-scoped, meaning it is accessible throughout the function in which it is defined. One unique characteristic of var is that it allows both redeclaration and reassignment, which can sometimes introduce bugs if not handled carefully.

Because of these limitations, developers rarely use var in modern applications unless maintaining legacy code.


Understanding let

The let keyword was introduced in ES6 and is now widely used. It provides block-level scope, meaning the variable is only accessible within the block {} where it is defined. This makes code more predictable and easier to debug.

Using let ensures that variables don’t accidentally leak outside their intended scope.


Understanding const

The const keyword is used to declare variables whose values should not change. Once assigned, a const variable cannot be reassigned. However, if the variable holds an object or array, its internal properties can still be modified.

This makes const ideal for values that should remain constant throughout the program.


Key Differences Between var, let, and const

Scope Explained

KeywordScope Type
varFunction/Global
letBlock
constBlock

Reassignment vs Redeclaration

KeywordReassignRedeclare
varYesYes
letYesNo
constNoNo

Hoisting Behavior

JavaScript uses a mechanism called hoisting, where variable declarations are moved to the top of their scope during execution. However, var is initialized with undefined, while let and const remain uninitialized until execution reaches their declaration.


Rules for Naming Variables

Valid Naming Conventions

  • Start with a letter, _, or $
  • Can include numbers (not at the beginning)
  • Case-sensitive

Common Mistakes to Avoid

  • Using reserved keywords
  • Starting names with numbers
  • Using unclear variable names

Rules to define a variable name

✅ 1. Allowed Characters

  • Variable names can contain:
    • Letters (a–z, A–Z)
    • Digits (0–9)
    • Underscore (_)
    • Dollar sign ($)

✔ Example:


❌ 2. Cannot Start with a Number

  • A variable name must NOT start with a digit

❌ Wrong:

✔ Correct:


❌ 3. No Spaces Allowed

  • Variable names cannot contain spaces

❌ Wrong:

let user name;

✔ Correct:

let userName;

❌ 4. Cannot Use Reserved Keywords

  • You cannot use JavaScript reserved words like:
    • let, var, const, if, else, function, etc.

❌ Wrong:

let var = 10;

✅ 5. Case Sensitive

  • JavaScript is case-sensitive
let name = "John";
let Name = "Doe"; // different variable

✅ 6. Use Meaningful Names (Best Practice)

  • Always use descriptive names

✔ Good:

let userAge = 25;
let totalPrice = 100;

❌ Bad:

let x = 25;

✅ 7. Use camelCase (Convention)

  • JavaScript commonly uses camelCase

✔ Example:

let firstName;
let totalAmount;

✅ 8. Avoid Special Characters

  • Do NOT use symbols like @, #, %, etc.

❌ Wrong:

let user@name;

✅ 9. Use let, const, or var

  • Modern JavaScript prefers:
    • let → for changeable values
    • const → for constants
let age = 20;
const PI = 3.14;

✎ Practise what you learned: 32 JavaScript variables programs with solutions →

Automation Practice Page

Text Fields





Radio Buttons



Checkboxes



Dropdown (Select)

Multi Select Dropdown

Buttons



JavaScript Alerts



File Upload

Date and Time Pickers





Links

Open Google
Go to Bottom

Web Table

ID Name Role
1 Deepesh Trainer
2 Rahul Tester
3 Anita Developer

Iframe

Hidden Element

Enabled & Disabled Fields



Image

Sample Image

Mouse Hover

Bottom of Page

This is the bottom of the page for scrolling practice.

Ultimate Automation Practice Page

Auto Suggestions (Google Style)

AJAX Success & Network Failure

Stale Element Simulation

Drag and Drop

Drag Me


Drop Here

Keyboard Actions

Nested Shadow DOM

Login Page

mysocial

Connect with friends and the world around you on MySocial.

Robot Framework Automation with AI Integration (Beginner to Advanced)

course fee poster


Course highlights

    • Training Mode: Online Zoom Session

    • Duration: 1 Month

    • Recorded sessions are available

    • Daily 1 hr sessions from Monday to Friday.

    • Instructor Name: Deepesh Yadav

Course Content

Module 1: Introduction to Robot Framework

    • Overview of Test Automation

    • Features and Advantages of Robot Framework

    • Installation and Setup (Python, PIP, Robot Framework, IDEs)

    • Directory Structure and Test Suite Organization

    • Writing the First Test Case

    • Executing Tests via Command Line and IDE


Module 2: Core Syntax and Test Structures

    • Test Cases, Keywords, and Variables

    • Settings, Variables, Test Cases, and Keywords Sections

    • Built-In Libraries Overview (String, Collections, DateTime, etc.)

    • Using Tags, Documentation, and Metadata

    • Logging and Reporting


Module 3: Working with SeleniumLibrary

    • Installing and Importing SeleniumLibrary

    • Browser Interaction (Open Browser, Click Element, Input Text, etc.)

    • Locators and XPath Strategies

    • Waits, Timeouts, and Synchronization

    • Handling Alerts, Windows, and Frames

    • Taking Screenshots and Validating UI Elements

    • Cross-Browser Testing


Module 4: API Automation with Robot Framework

    • Introduction to API Testing

    • Working with RequestsLibrary

    • GET, POST, PUT, DELETE Methods

    • Handling Authentication (Basic, Bearer Tokens)

    • Validating JSON/XML Responses

    • Schema Validation

    • Integrating with External Data (CSV, Excel, JSON)


Module 5: AI Integration

    • Overview of AI in Test Automation

    • Integration of ChatGPT, Copilot, and Cursor for Intelligent Test Generation

    • Using AI to Auto-Generate Test Cases and Keywords

    • AI-driven Code Suggestions in PyCharm and VS Code

    • Automating Test Documentation with AI

    • Integrating AI Chatbots with Robot Framework

    • Smart Error Analysis using AI Models


Module 6: GitHub and Version Control Integration

    • Git Basics and Repository Setup

    • Pushing and Pulling Robot Test Projects

    • Branching, Merging, and Conflict Resolution

    • Integrating GitHub Actions with Robot Framework

    • CI/CD Pipeline Overview


Module 7: PyCharm Integration

    • Installing and Configuring PyCharm for Robot Framework

    • Plugins and Run Configurations

    • Debugging Robot Tests in PyCharm

    • Code Completion and Keyword Assistance

    • Integrating AI Tools (Copilot, Cursor, ChatGPT in PyCharm)


Module 8: Data-Driven and Keyword-Driven Frameworks

    • Creating Reusable Custom Keywords

    • Working with Resource Files

    • Using Variables and Dynamic Test Data

    • Reading Data from Excel, CSV, JSON

    • Implementing Keyword-Driven Frameworks

    • Parameterized and Loop-Driven Test Cases


Module 9: Advanced Framework Design

    • Designing Scalable Automation Frameworks

    • Modular Test Architecture

    • Error Handling and Retry Logic

    • Parallel Test Execution (Pabot Integration)

    • Custom Library Development in Python

    • Integrating Database Testing

    • Working with API + UI Combined Tests


Module 10: CI/CD and Jenkins Integration

    • Jenkins Overview and Setup

    • Creating Jenkins Pipeline for Robot Tests

    • Running Tests from GitHub via Jenkins

    • Generating HTML Reports in Jenkins

    • Automated Notifications (Slack/Email Integration)

    • Using Docker Containers for Test Execution


Module 11: Reporting and Analytics

    • Default Robot Framework Reports and Logs

    • Generating Custom HTML Reports

    • Integrating with Allure Reports

    • Visualizing Test Metrics

    • AI-based Test Report Analysis


Module 12: Real-World Projects

    • End-to-End Web Application Automation

    • REST API + UI Automation Combined Framework

    • Continuous Integration Pipeline Project

    • AI-Assisted Automation Project using ChatGPT API


Module 13: Best Practices and Interview Preparation

    • Framework Design Best Practices

    • Common Interview Questions for Robot Framework and Python Automation

    • Industry Use Cases and Portfolio Building

    • Live Project to automate end-to-end Scenarios and Integration with CI/CD Pipeline.

Students Feedback

Join tuples with the same first element

Python Practice › Tuple Programs › Program 17

Join tuples with the same first element

MediumTuple Programs · 17 of 70

Write a Python program to join tuples that start with the same element.

Input
[(3, 6, 7), (7, 8, 4), (7, 3), (3, 0, 5)]
Output
[(3, 6, 7, 0, 5), (7, 8, 4, 3)]

Approach

  1. Group by the first element in a dict, appending the rest of each tuple.

Solution

Python
data = [(3, 6, 7), (7, 8, 4), (7, 3), (3, 0, 5)]groups = {}for first, *rest in data:    groups.setdefault(first, [first]).extend(rest)print([tuple(v) for v in groups.values()])
Output
[(3, 6, 7, 0, 5), (7, 8, 4, 3)]

Line by line

Line 3

first, *rest splits each tuple into its first item and the remaining items.

Line 4

The first time a key appears, its list starts as [first]; later tuples only add their remaining items.

Learn the concept

New to this topic? Read the lesson, then come back.

More tuple programs

← All 70 Tuple Programs

Add values row by row to a tuple matrix

Python Practice › Tuple Programs › Program 14

Add values row by row to a tuple matrix

MediumTuple Programs · 14 of 70

Write a Python program to add one value from a tuple to each row of a tuple matrix.

Input
A = [[("sqa", 4)], [("tools", 8)]], B = (3, 6)
Output
[[('sqa', 4, 3)], [('tools', 8, 6)]]

Approach

  1. Pair each row with its value using zip, then extend every tuple in the row.

Solution

Python
A = [[("sqa", 4)], [("tools", 8)]]B = (3, 6)result = [[t + (value,) for t in row] for row, value in zip(A, B)]print(result)
Output
[[('sqa', 4, 3)], [('tools', 8, 6)]]

Line by line

Line 3

zip(A, B) pairs the first row with 3 and the second with 6; each tuple gets that value appended.

Learn the concept

New to this topic? Read the lesson, then come back.

More tuple programs

← All 70 Tuple Programs

Dummy Booking Website

Practice end-to-end flight booking for automation testing: log in, search flights, pick a flight and seats, enter passenger details and pay with dummy test data. Every element has a stable id and data-testid for Selenium and Playwright practice.

Dummy Ticket Booking Website

SkyTrip practice airline: a safe, fake booking flow for automation testing. No real flights or payments.
Signed in as Test User
  1. 1Search
  2. 2Select flight
  3. 3Passengers
  4. 4Seats
  5. 5Payment
  6. 6Confirmation

Select your flight

Traveller details

Enter names exactly as on the passport or ID. All fields marked * are required.

Contact details

Choose your seats

Pick a seat for each traveller on each flight. Infants sit on an adult’s lap.

FreeExtra legroom ₹800 OccupiedSelected traveller Your other travellers

Review and pay

This is a dummy payment. Only the test details listed below are accepted.

Practice only: use card 4111 1111 1111 1111, UPI success@upi or any bank. Do not enter real card details.
Processing payment…

is_selected Method

The is_selected() method in Selenium is used to check whether a web element, such as a checkbox, radio button, or option in a dropdown, is currently selected or not. It returns True if the element is selected and False if it is not.

Syntax:

element.is_selected()

Example:

from selenium import webdriver
from selenium.webdriver.common.by import By

#
Set up the driver (assuming you're using Chrome)
driver = webdriver.Chrome()

#
Open a webpage with website example
driver.get('https://example.com')

#
Locate a checkbox or radio button element
checkbox = driver.find_element(By.ID, 'checkbox_id')

#
Check if the checkbox is selected
if checkbox.is_selected():
print("The checkbox is selected.")
else:
print("The checkbox is not selected.")

#
Close the browser
driver.quit()

Example with checkbox selection

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

driver.implicitly_wait(20)
driver.maximize_window()

#
Open dummy website on the browser
driver.get('
https://sqatools.in/dummy-booking-website/')

#
get the "Remember me" checkbox
checkbox_element = driver.find_element(By.ID, "remember-me")

#
check is_selected status before selecting checkbox
print("is_selected status:", checkbox_element.is_selected()) # False

checkbox_element.click()

#
check is_selected status after selecting checkbox
print("is_selected status:", checkbox_element.is_selected()) # True

#
Close browser
driver.quit()


Explanation:

  • element.is_selected() works primarily for form elements like checkboxes, radio buttons, and options within a <select> dropdown.

  • If the element is selected (checked for a checkbox, selected for a radio button or dropdown option), it returns True. Otherwise, it returns False.

This method is useful when you need to verify the state of form elements before taking further action.


SQL REVOKE Statement

SQL Tutorial › Security › REVOKE

SQL REVOKE Statement

IntermediateLesson 68 of 697 min read5 queries run on MySQL 8.4

REVOKE is the opposite of GRANT: it takes privileges away from an account or role. You need it when someone changes team, when an application no longer needs write access, or after an audit finds an account with too much power. The privileges are removed immediately.

In this lesson
  • Revoke individual privileges and all privileges
  • Revoke roles and the grant option
  • Verify with SHOW GRANTS
  • Avoid the “revoke at a different level” trap

REVOKE syntax

MySQL
REVOKE privilege [, privilege ...]ON levelFROM 'user'@'host';

The level must match how the privilege was granted (company.*, company.orders, …).

Revoke one privilege

The shop application should no longer delete rows (it uses soft deletes now):

MySQL
CREATE USER 'shop_app'@'localhost' IDENTIFIED BY 'Sh0p#App2026';GRANT SELECT, INSERT, UPDATE, DELETE ON company.* TO 'shop_app'@'localhost';REVOKE DELETE ON company.* FROM 'shop_app'@'localhost';SHOW GRANTS FOR 'shop_app'@'localhost';
ResultMySQL 8.4
mysql> CREATE USER 'shop_app'@'localhost' IDENTIFIED BY 'Sh0p
Query OK, 0 rows affected
mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON company.* TO 'shop_app'@'local…
Query OK, 0 rows affected
mysql> REVOKE DELETE ON company.* FROM 'shop_app'@'localhost'
Query OK, 0 rows affected
mysql> SHOW GRANTS FOR 'shop_app'@'localhost'
Grants for shop_app@localhost
GRANT USAGE ON *.* TO `shop_app`@`localhost`
GRANT SELECT, INSERT, UPDATE ON `company`.* TO `shop_app`@`localhost`
2 rows in set
How this query works, step by step
  1. The account starts with four privileges on company.*.
  2. REVOKE DELETE removes one; SHOW GRANTS now lists SELECT, INSERT, UPDATE.
  3. The change applies to new statements immediately, even in sessions that are already connected.

Revoke everything

MySQL
CREATE USER 'contractor'@'localhost' IDENTIFIED BY 'C0ntract#2026';GRANT SELECT, INSERT ON company.* TO 'contractor'@'localhost';GRANT SELECT ON company.employees TO 'contractor'@'localhost';REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'contractor'@'localhost';SHOW GRANTS FOR 'contractor'@'localhost';
ResultMySQL 8.4
mysql> CREATE USER 'contractor'@'localhost' IDENTIFIED BY 'C0ntract
Query OK, 0 rows affected
mysql> GRANT SELECT, INSERT ON company.* TO 'contractor'@'localhost'
Query OK, 0 rows affected
mysql> GRANT SELECT ON company.employees TO 'contractor'@'localhost'
Query OK, 0 rows affected
mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'contractor'@'localhost'
Query OK, 0 rows affected
mysql> SHOW GRANTS FOR 'contractor'@'localhost'
Grants for contractor@localhost
GRANT USAGE ON *.* TO `contractor`@`localhost`
1 row in set
How this query works, step by step
  1. The contractor had privileges at two levels: database and table.
  2. REVOKE ALL PRIVILEGES, GRANT OPTION FROM ... (without ON) removes them at every level.
  3. Only USAGE remains: the account can log in but do nothing. To remove the account completely, DROP USER.

The level trap

A privilege granted at database level cannot be revoked for one table:

MySQL
CREATE USER 'analyst1'@'localhost' IDENTIFIED BY 'An@lyst2026';GRANT SELECT ON company.* TO 'analyst1'@'localhost';REVOKE SELECT ON company.employees FROM 'analyst1'@'localhost';
ResultMySQL 8.4
mysql> CREATE USER 'analyst1'@'localhost' IDENTIFIED BY 'An@lyst2026'
Query OK, 0 rows affected
mysql> GRANT SELECT ON company.* TO 'analyst1'@'localhost'
Query OK, 0 rows affected
mysql> REVOKE SELECT ON company.employees FROM 'analyst1'@'localhost'
ERROR 1147 (42000): There is no such grant defined for user 'analyst1' on host 'localhost' on table 'employees'
How this query works, step by step
  1. SELECT was granted on company.*, not on company.employees.
  2. There is no table-level grant to remove, so MySQL reports error 1147.
  3. To give “all tables except employees”, revoke the database grant and grant SELECT table by table (or through views).

Revoke a role

MySQL
CREATE ROLE 'analyst';GRANT SELECT ON company.* TO 'analyst';CREATE USER 'priya'@'localhost' IDENTIFIED BY 'Pr1ya#2026';GRANT 'analyst' TO 'priya'@'localhost';REVOKE 'analyst' FROM 'priya'@'localhost';SHOW GRANTS FOR 'priya'@'localhost';
ResultMySQL 8.4
mysql> CREATE ROLE 'analyst'
Query OK, 0 rows affected
mysql> GRANT SELECT ON company.* TO 'analyst'
Query OK, 0 rows affected
mysql> CREATE USER 'priya'@'localhost' IDENTIFIED BY 'Pr1ya
Query OK, 0 rows affected
mysql> GRANT 'analyst' TO 'priya'@'localhost'
Query OK, 0 rows affected
mysql> REVOKE 'analyst' FROM 'priya'@'localhost'
Query OK, 0 rows affected
mysql> SHOW GRANTS FOR 'priya'@'localhost'
Grants for priya@localhost
GRANT USAGE ON *.* TO `priya`@`localhost`
1 row in set

Changing the role itself (REVOKE INSERT ON company.* FROM 'developer';) changes the access of every account that has the role.

Revoke the grant option

MySQL
CREATE USER 'team_lead'@'localhost' IDENTIFIED BY 'L3ad#2026';GRANT SELECT ON company.* TO 'team_lead'@'localhost' WITH GRANT OPTION;REVOKE GRANT OPTION ON company.* FROM 'team_lead'@'localhost';SHOW GRANTS FOR 'team_lead'@'localhost';
ResultMySQL 8.4
mysql> CREATE USER 'team_lead'@'localhost' IDENTIFIED BY 'L3ad
Query OK, 0 rows affected
mysql> GRANT SELECT ON company.* TO 'team_lead'@'localhost' WITH GRANT OPTION
Query OK, 0 rows affected
mysql> REVOKE GRANT OPTION ON company.* FROM 'team_lead'@'localhost'
Query OK, 0 rows affected
mysql> SHOW GRANTS FOR 'team_lead'@'localhost'
Grants for team_lead@localhost
GRANT USAGE ON *.* TO `team_lead`@`localhost`
GRANT SELECT ON `company`.* TO `team_lead`@`localhost`
2 rows in set

The team lead keeps SELECT but can no longer give it to others.

Quick quiz

1. How do you remove all privileges of an account at every level?

2. SELECT was granted ON company.*. What happens with REVOKE SELECT ON company.orders?

3. Does a REVOKE affect sessions that are already connected?

REVOKE FAQ

What is the difference between GRANT and REVOKE?

GRANT gives privileges to an account or role; REVOKE removes them.

How do I remove all privileges from a MySQL user?

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'host'; The account keeps only USAGE. Use DROP USER to delete it.

Why does REVOKE give error 1141 or 1147?

The privilege was not granted at the level you named. Check with SHOW GRANTS and revoke at the same level (db.*, db.table or global).