Skip to content

Instantly share code, notes, and snippets.

@humayunahmed8
Last active June 28, 2018 10:51
Show Gist options
  • Save humayunahmed8/9715360f2db786873b9f055c7957a437 to your computer and use it in GitHub Desktop.
Save humayunahmed8/9715360f2db786873b9f055c7957a437 to your computer and use it in GitHub Desktop.
Javascript Operators
// Arithmatical Operator
var x=130;
var y=90;
document.write(x+y); // Addition
document.write('<br/>');
document.write(x-y); // Substaction
document.write('<br/>');
document.write(x*y); // Multiplication
document.write('<br/>');
document.write(x/y); // Division
document.write('<br/>');
document.write(x%y); // Modulas
// Unary operators (Increment/Decrement)
var x = 25;
var y = 20;
document.write(x++);
document.write('<br/>');
document.write(++x);
document.write('<br/>');
document.write(x++);
document.write('<br/>');
document.write(x--);
document.write('<br/>');
document.write(x++);
// Asignment Operator
var x = 40;
var y = 40;
document.write(x+=y); // x=x+y =80
document.write('<br/>');
document.write(x-=y); // x=x-y =40
document.write('<br/>');
document.write(x*=y); // x=x*y =1600
document.write('<br/>');
document.write(x/=y); // x=x/y =40
document.write('<br/>');
document.write(x%=y); //x=x%y =0
// Comparison Operartor
var x = 20;
var y = '20';
document.write(x>y); //false
document.write('<br/>');
document.write(x>=y); //true
document.write('<br/>');
document.write(x<y); //false
document.write('<br/>');
document.write(x==y); //true
document.write('<br/>');
document.write(x!=y); //false
document.write('<br/>');
document.write(x===y); //false
document.write('<br/>');
document.write(x!==y); //true
document.write('<br/>');
// Logical Operator
var x = 40;
var y = 30;
var z = 40;
var a = true;
document.write((x<y)&&(x<y)); //less than
document.write('<br/>');
document.write((x>y)||(x<y)); // or
document.write('<br/>');
document.write(!a); //it will be reverse this variable data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment