Values and Operators in JS

Photo by James Harrison on Unsplash


var a = 14;
var b = 56.27;
var c = -45;
// in the above code snippets, there are three data, stored by the // name of 'a, b & c' having a value attached to them, i.e, 15,
// 56.27 & -45 respectively. All these values are number of NUMBER // DATATYPE.
  • ``- Backticks- Includes features to include JS code inside it
  • ‘ ’- Single quotes- Normal way of declaring String
  • “ ”- Double quotes- Same as above, matter of personal preference
var name = `Dash`;
var job = 'Developer';
var sentence = "Dash is a web developer."
// as you see I have used three different types of quote marks, but // all of them essentially mean that the data type of the value is // of STRING DATATYPE
var somethingRight = true;
var somethingWrong = false;
// the above value of data are BOOLEAN DATATYPE
// they can't hold any other value, just true and false.
var universe = null;// the variable universe doesn't contain anything. It is NULL.
// undefined values appear when a code snippet has to give some
// values but doesn't know what value to give.


  • Unary operator- These operators work on one operand, such as typeof()
typeof('Hello World!');// the output will be String, why? Because it is wrapped inside 
// single quotes. Remember from the previous section? Awesome.
// it is just one example of unary operators, there are a few others // too.
  • Binary operators- These work on 2 operands, such as +, -, /, *, %
console.log( 20 + 30 );// output will 50. As you see, '+' is a binary operator, working on // two operands (20 & 30). 
  • Ternary operator- There is only one of these. It works with three operands.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store