Special Operators you don’t know


The comma operator (,) evaluates each of its operands (from left to right) and returns the value of the last operand.

This is commonly used to provide multiple parameters to a for loop.

for (var i = 0, j = 9; i <= 9; i++, j–)

console. log ( ‘a[‘ +i + ‘][‘ + j + ‘] = ‘+ a[i][j]);


The new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function.

function Person (name, age, sex) {

this.name name;

this.age = age;

this.sex = sex;


var rand new Person ( ‘Rand McNally ‘, 33, ‘M’);

var ken = new Person ( “Ken Jones’, 39, ‘M’);


The JavaScript delete operator removes a property from an object; if no more references to the same property are held, it is eventually released automatically.

var Employee  = {

age: 28,


designation: ‘developer’


console.log(delete Employee.name);

/ / returns true

console. log (delete Employee.age) ;

/ / returns true

/ / When trying to delete a property that does

/ /  not exist, true is returned

console. log (delete Employee. salary) ; / / returns true


The in operator returns true if the specified property is in the specified object or its prototype chain.

// Custom objects

let my car = {make: ‘Honda’, model: “Accord’, year: 1998}

‘make’ in my car // returns true

‘model’ in my car // returns true


The typeof operator returns a string indicating the type of the unevaluated operand.

 console.log (typeof 42);

/ / expected output: “number”

 console. log(typeof ‘blubber ‘);

/ / expected output: “string”

console. log(typeof true);

/ / expected output: “boolean”

console. log (type of undeclaredVariable);

/ / expected output: “undefined “

Leave a Reply

Your email address will not be published. Required fields are marked *