
Domains
Agile Management
Master Agile methodologies for efficient and timely project delivery.
View All Agile Management Coursesicon-refresh-cwCertifications
Scrum Alliance
16 Hours
Best Seller
Certified ScrumMaster (CSM) CertificationScrum Alliance
16 Hours
Best Seller
Certified Scrum Product Owner (CSPO) CertificationScaled Agile
16 Hours
Trending
Leading SAFe 6.0 CertificationScrum.org
16 Hours
Professional Scrum Master (PSM) CertificationScaled Agile
16 Hours
SAFe 6.0 Scrum Master (SSM) CertificationAdvanced Certifications
Scaled Agile, Inc.
32 Hours
Recommended
Implementing SAFe 6.0 (SPC) CertificationScaled Agile, Inc.
24 Hours
SAFe 6.0 Release Train Engineer (RTE) CertificationScaled Agile, Inc.
16 Hours
Trending
SAFe® 6.0 Product Owner/Product Manager (POPM)IC Agile
24 Hours
ICP Agile Certified Coaching (ICP-ACC)Scrum.org
16 Hours
Professional Scrum Product Owner I (PSPO I) TrainingMasters
32 Hours
Trending
Agile Management Master's Program32 Hours
Agile Excellence Master's ProgramOn-Demand Courses
Agile and ScrumRoles
Scrum MasterTech Courses and Bootcamps
Full Stack Developer BootcampAccreditation Bodies
Scrum AllianceTop Resources
Scrum TutorialProject Management
Gain expert skills to lead projects to success and timely completion.
View All Project Management Coursesicon-standCertifications
PMI
36 Hours
Best Seller
Project Management Professional (PMP) CertificationAxelos
32 Hours
PRINCE2 Foundation & Practitioner CertificationAxelos
16 Hours
PRINCE2 Foundation CertificationAxelos
16 Hours
PRINCE2 Practitioner CertificationSkills
Change ManagementMasters
Job Oriented
45 Hours
Trending
Project Management Master's ProgramUniversity Programs
45 Hours
Trending
Project Management Master's ProgramOn-Demand Courses
PRINCE2 Practitioner CourseRoles
Project ManagerAccreditation Bodies
PMITop Resources
Theories of MotivationCloud Computing
Learn to harness the cloud to deliver computing resources efficiently.
View All Cloud Computing Coursesicon-cloud-snowingCertifications
AWS
32 Hours
Best Seller
AWS Certified Solutions Architect - AssociateAWS
32 Hours
AWS Cloud Practitioner CertificationAWS
24 Hours
AWS DevOps CertificationMicrosoft
16 Hours
Azure Fundamentals CertificationMicrosoft
24 Hours
Best Seller
Azure Administrator CertificationMicrosoft
45 Hours
Recommended
Azure Data Engineer CertificationMicrosoft
32 Hours
Azure Solution Architect CertificationMicrosoft
40 Hours
Azure DevOps CertificationAWS
24 Hours
Systems Operations on AWS Certification TrainingAWS
24 Hours
Developing on AWSMasters
Job Oriented
48 Hours
New
AWS Cloud Architect Masters ProgramBootcamps
Career Kickstarter
100 Hours
Trending
Cloud Engineer BootcampRoles
Cloud EngineerOn-Demand Courses
AWS Certified Developer Associate - Complete GuideAuthorized Partners of
AWSTop Resources
Scrum TutorialIT Service Management
Understand how to plan, design, and optimize IT services efficiently.
View All DevOps Coursesicon-git-commitCertifications
Axelos
16 Hours
Best Seller
ITIL 4 Foundation CertificationAxelos
16 Hours
ITIL Practitioner CertificationPeopleCert
16 Hours
ISO 14001 Foundation CertificationPeopleCert
16 Hours
ISO 20000 CertificationPeopleCert
24 Hours
ISO 27000 Foundation CertificationAxelos
24 Hours
ITIL 4 Specialist: Create, Deliver and Support TrainingAxelos
24 Hours
ITIL 4 Specialist: Drive Stakeholder Value TrainingAxelos
16 Hours
ITIL 4 Strategist Direct, Plan and Improve TrainingOn-Demand Courses
ITIL 4 Specialist: Create, Deliver and Support ExamTop Resources
ITIL Practice TestData Science
Unlock valuable insights from data with advanced analytics.
View All Data Science Coursesicon-dataBootcamps
Job Oriented
6 Months
Trending
Data Science BootcampJob Oriented
289 Hours
Data Engineer BootcampJob Oriented
6 Months
Data Analyst BootcampJob Oriented
288 Hours
New
AI Engineer BootcampSkills
Data Science with PythonRoles
Data ScientistOn-Demand Courses
Data Analysis Using ExcelTop Resources
Machine Learning TutorialDevOps
Automate and streamline the delivery of products and services.
View All DevOps Coursesicon-terminal-squareCertifications
DevOps Institute
16 Hours
Best Seller
DevOps Foundation CertificationCNCF
32 Hours
New
Certified Kubernetes AdministratorDevops Institute
16 Hours
Devops LeaderSkills
KubernetesRoles
DevOps EngineerOn-Demand Courses
CI/CD with Jenkins XGlobal Accreditations
DevOps InstituteTop Resources
Top DevOps ProjectsBI And Visualization
Understand how to transform data into actionable, measurable insights.
View All BI And Visualization Coursesicon-microscopeBI and Visualization Tools
Certification
24 Hours
Recommended
Tableau CertificationCertification
24 Hours
Data Visualization with Tableau CertificationMicrosoft
24 Hours
Best Seller
Microsoft Power BI CertificationTIBCO
36 Hours
TIBCO Spotfire TrainingCertification
30 Hours
Data Visualization with QlikView CertificationCertification
16 Hours
Sisense BI CertificationOn-Demand Courses
Data Visualization Using Tableau TrainingTop Resources
Python Data Viz LibsCyber Security
Understand how to protect data and systems from threats or disasters.
View All Cyber Security Coursesicon-refresh-cwCertifications
CompTIA
40 Hours
Best Seller
CompTIA Security+EC-Council
40 Hours
Certified Ethical Hacker (CEH v12) CertificationISACA
22 Hours
Certified Information Systems Auditor (CISA) CertificationISACA
40 Hours
Certified Information Security Manager (CISM) Certification(ISC)²
40 Hours
Certified Information Systems Security Professional (CISSP)(ISC)²
40 Hours
Certified Cloud Security Professional (CCSP) Certification16 Hours
Certified Information Privacy Professional - Europe (CIPP-E) CertificationISACA
16 Hours
COBIT5 Foundation16 Hours
Payment Card Industry Security Standards (PCI-DSS) CertificationOn-Demand Courses
CISSPTop Resources
Laptops for IT SecurityWeb Development
Learn to create user-friendly, fast, and dynamic web applications.
View All Web Development Coursesicon-codeBootcamps
Career Kickstarter
6 Months
Best Seller
Full-Stack Developer BootcampJob Oriented
3 Months
Best Seller
UI/UX Design BootcampEnterprise Recommended
6 Months
Java Full Stack Developer BootcampCareer Kickstarter
490+ Hours
Front-End Development BootcampCareer Accelerator
4 Months
Backend Development Bootcamp (Node JS)Skills
ReactOn-Demand Courses
Angular TrainingTop Resources
Top HTML ProjectsBlockchain
Understand how transactions and databases work in blockchain technology.
View All Blockchain Coursesicon-stop-squareBlockchain Certifications
40 Hours
Blockchain Professional Certification32 Hours
Blockchain Solutions Architect Certification32 Hours
Blockchain Security Engineer Certification24 Hours
Blockchain Quality Engineer Certification5+ Hours
Blockchain 101 CertificationOn-Demand Courses
NFT Essentials 101: A Beginner's GuideTop Resources
Blockchain Interview QsProgramming
Learn to code efficiently and design software that solves problems.
View All Programming Coursesicon-codeSkills
Python CertificationInterview Prep
Career Accelerator
3 Months
Software Engineer Interview PrepOn-Demand Courses
Data Structures and Algorithms with JavaScriptTop Resources
Python TutorialJust like any other programming language JavaScript have operators, which works generally on two operands. If there is an expression 5 + 6 then 5 and 6 are operands and + is the operator.
JavaScript supports the following types of operators.
Let’s now look into them in detail.
JS supports the following arithmetic operators.
It adds two operands if they are number. In case one or both operands are string, it will concatenate them.
var a = 10;
var b = 20;
console.log(a + b); //30
var str = "stingValue";
console.log(a + str); //10stingValue
It subtracts the second operand from the first.
var a = 10;
var b = 20;
console.log(a - b); //-10
It multiplies both operands.
var a = 10;
var b = 20;
console.log(a * b); //200
It divides the numerator by the denominator.
var a = 20;
var b = 10;
var c = 3;
console.log(a / b); //2
console.log(a / c); //6.666666666666667
It outputs the remainder which we get when we divide the numerator by the denominator.
var a = 20;
var b = 10;
var c = 3;
console.log(a / b); //2
console.log(a / c); //6.666666666666667
It is one of the few operators which works on only one operand. It is used to increase the integer value by 1.
One thing to notice that it behaves a bit different if used before or after the operand as shown in below code. If we use it before the operand, it updates the variable value instantly.
Whether as if we use it after the operand, it increases the value in memory but don’t update instantly.
var a = 20;
var b = 10;
console.log(++a); //21
console.log(b++); //10
console.log(a); //21
console.log(b); //11
It works like the increment operator. It is used to decrease the integer value by 1.
var a = 20;
var b = 10;
console.log(--a); //19
console.log(b--); //10
console.log(a); //19
console.log(b); //9
JS supports the following comparison operators.
Compares where two operands are equal or not. Returns a Boolean true or false depending on the comparison.
One thing to notice is that, if one of the operands to compare is different it converts it to number. Here, variable a and c are different because a is number and c is a string. But the comparison gives true because c is converted to a number before comparison.
var a = 20;
var b = 10;
var c = '20';
console.log(a == b); //false
console.log(a == c); //true
Just like the Equal(==) operator, compares where two operands are equal or not. Returns a Boolean true or false depending on the comparison.
But it does a strict comparison. It will not do any type of change for operands before comparing. So, the code with 20 === '20' will produce false.
var a = 20;
var b = 10;
var c = '20';
console.log(a === b); //false
console.log(a === c); //false
It is the opposite of Equal(==) operator, compares whether two operands are not equal. Returns a Boolean false or true depending on the comparison.
But it doesn’t do a strict comparison. It is just like Equal(==) operator, where it converts if the two operands are not of the same data type. So, the code with 20 != '20' will produce false.
var a = 20;
var b = 10;
var c = '20';
console.log(a != b); //true
console.log(a != c); //false
Just like Not Equal(!=) operator, compares whether two operands are not equal. Returns a Boolean false or true depending on the comparison.
But it does a strict comparison. It will not do any type of change for operands before comparing. So, the code with 20 !== '20' will produce true.
var a = 20;
var b = 10;
var c = '20';
console.log(a !== b); //true
console.log(a !== c); //true
The Greater than(>) operator, checks whether the left operand is greater than the value of the right operand. It returns true if it is or else returns false
var a = 20;
var b = 10;
var c = 30;
console.log(a > b); //true
console.log(a > c); //false
The Less than(>) operator, checks whether the left operand is less than the value of the right operand. It returns true if it is or else returns false
var a = 20;
var b = 10;
var c = 30;
console.log(a < b); //false
console.log(a < c); //true
The Greater than or equal to(>=) operator, checks whether the left operand is greater than or equal to the value of the right operand. It returns true if it is or else returns false.
var a = 20;
var b = 10;
var c = 30;
var d = 20;
console.log(a >= b); //true
console.log(a >= c); //false
console.log(a >= d); //true
The Less than or equal to(<=) operator, checks whether the left operand is less than or equal to the value of the right operand. It returns true if it is or else returns false.
var a = 20;
var b = 10;
var c = 30;
var d = 20;
console.log(a <= b); //false
console.log(a <= c); //true
console.log(a <= d); //true
JS supports the following logical operators – Logical AND(&&), Logical OR(||) and Logical Not(!).
We will discuss Logical AND(&&) and Logical OR(||) in detail here because Logical Not(!) just reverses the logical state of its operand. If a condition is true, then the Logical NOT operator will make it false.
Using only the two boolean values true and false, we can generate the truth tables below.
It means logical AND(&&) is only true if both operands are true.
But even if one operand is true in case of logical OR(||), it will return true.
//Logical AND Operation
console.log(true && true); //true
console.log(true && false); //false
console.log(false && true); //false
console.log(false && false);//false
//Logical OR Operation
console.log(true || true); //true
console.log(true || false); //true
console.log(false || true); //true
console.log(false || false); //false
In JavaScript, the logical operators can operate on expressions of any type, not just booleans. Also, the logical operators do not always return a boolean value
One more thing to understand is that JavaScript considers some values as “falsy” and will always return false. Everything else is “truthy” in JavaScript. The following are the six "falsy" values:
Both && and || result in the value of (exactly) one of their operands:
The below code example, shows the same.
console.log(0 || 1); //1
console.log(1 || 2); //1
console.log(0 && 1); //0
console.log(1 && 2); //2
JavaScript bitwise operators works on 32-bit numbers. So, the numeric operands are first converted into 32-bit number. The result is converted back to JavaScript number.
JS supports the following bitwise operators –
It performs Boolean AND operation on each bit of the operands.
Eg -
console.log(5 & 1); //1
/* 5 & 1
gets converted into 0101 & 0001,
which will result in 0001 and
it get converted back to decimal 1 */
It performs Boolean OR operation on each bit of the operands.
Eg -
console.log(5 | 1); //5
/* 5 | 1
gets converted into 0101 | 0001,
which will result in 0101 and
it get converted back to decimal 5 */
It works on one operand only and reverses all of its bits.
Eg -
console.log(~5); //-6
/* ~5
gets converted into ~00000000000000000000000000000101 ,
which will result in 11111111111111111111111111111010 and
it get converted back to decimal -6 */
It performs Boolean Exclusive OR operation on each bit of the operands.
Eg -
console.log(5 ^ 1); //4
/* 5 ^ 1
gets converted into 0101 ^ 0001,
which will result in 0100 and
it get converted back to decimal 4 */
It moves all the bits in its first operand to the left by the number of places specified in the second operand. New bits are filled with zeros.
Eg -
console.log(5 << 1); //10
/* 5 << 1
gets converted into 0101 << 1,
which will result in 1010 and
it get converted back to decimal 10 */
It moves all the bits in its first operand to the right by the number of places specified in the second operand. New bits are filled with zeros.
Eg -
console.log(5 >> 1); //2
/* 5 >> 1
gets converted into 0101 >> 1,
which will result in 0010 and
it get converted back to decimal 2 */
This operator is just like the >> operator, except that the bits shifted in on the left are always zero.
Eg -
console.log(5 >>> 1); //2
/* 5 >>> 1
gets converted into 0101 >>> 1,
which will result in 0010 and
it get converted back to decimal 2 */
JS supports the following assignment operators –
Assigns the value of the right-hand operand to the left-hand operand. The right-hand operand can be a simple number, string or a computation statement. The left operand is generally a variable.
Eg -
var num = 10;
var str = "StringValue";
var res = num + str;
console.log(res); //10StringValue
It adds the right operand to the left operand and assigns the value to the left operand. Actually, it is a short form of notation. The statement A += B is equivalent to A = A + B
Eg -
var num1 = 10;
var num2 = 5;
num1 += num2;
console.log(num1); //15
It subtracts the right operand to the left operand and assigns the value to the left operand. Actually, it is a short form of notation. The statement A -= B is equivalent to A = A - B
Eg -
var num1 = 10;
var num2 = 5;
num1 -= num2;
console.log(num1); //5
It multiplies the right operand to the left operand and assigns the value to the left operand. Actually, it is a short form of notation. The statement A *= B is equivalent to A = A * B
Eg -
var num1 = 10;
var num2 = 5;
num1 *= num2;
console.log(num1); //50
It divides the right operand to the left operand and assigns the value to the left operand. Actually, it is a short form of notation. The statement A /= B is equivalent to A = A / B
Eg -
var num1 = 10;
var num2 = 5;
num1 /= num2;
console.log(num1); //2
It divides the right operand to the left operand and assigns the remainder value to the left operand. Actually, it is a short form of notation. The statement A %= B is equivalent to
A = A % B
Eg -
var num1 = 10;
var num2 = 5;
num1 %= num2;
console.log(num1); //0
JS has the following two miscellaneous operators, which doesn’t fit into any category.
The conditional operator is quite similar to if…else statement and can be thought of a short-form to it. The conditional operator first evaluates an expression for a true or false value and then executes the first one if the result is true and the second one if the result is false.
Eg -
var num1 = 10;
var num2 = 5;
var res = num1 > num2 ? 'num1 is greater' : 'num2 is greater';
console.log(res); //num1 is greater
The typeof operator is a very useful unary operator, which can be used to find the data type any variable. Let consider the example below and we will see the typeof operator returns correctly the data type of the variables.
Eg -
var num = 10;
var str = "I am String";
var num2;
var bool = true;
var myFunc = function() {};
var myObj = {};
var num3 = null;
console.log(typeof num); //number
console.log(typeof str); //string
console.log(typeof num2); //undefined
console.log(typeof bool); //boolean
console.log(typeof myFunc); //function
console.log(typeof myObj); //object
console.log(typeof num3); //object
One of the things to notice here is that typeof null gives an object. Actually, this is a bug in JavaScript which was introduced during its creation in 1995. But this cannot be rectified anymore because a lot of code in the web depends on it and rectifying it will break a lot of websites.