/*****************************
* Variables and data types
*/
/*
var firstName = 'Rajat';
console.log(firstName);

var lastName = 'Smith';
var age = 28;

var fullAge = true;
console.log(fullAge);

var job;
console.log(job);

job = 'Teacher';
console.log(job);

// Variable naming rules
var _3years = 3;
var RajatMark = 'Rajat and MArk';
var if = 23;
*/



/*****************************
* Variable mutation and type coercion
*/
/*
var firstName = 'Rajat';
var age = 28;

// Type coercion
console.log(firstName + ' ' + age);

var job, isMarried;
job = 'teacher';
isMarried = false;

console.log(firstName + ' is a ' + age + ' year old ' + job + '. Is he married? ' + isMarried);

// Variable mutation
age = 'twenty eight';
job = 'driver';

alert(firstName + ' is a ' + age + ' year old ' + job + '. Is he married? ' + isMarried);

var lastName = prompt('What is his last Name?');
console.log(firstName + ' ' + lastName);
*/



/*****************************
* Basic operators
*/
/*
var year, yearRajat, yearMark;
now = 2020;
ageRajat = 28;
ageMark = 33;

// Math operators
yearRajat = now - ageRajat;
yeahMark = now - ageMark;

console.log(yearRajat);

console.log(now + 2);
console.log(now * 2);
console.log(now / 10);


// Logical operators
var RajatOlder = ageRajat < ageMark;
console.log(RajatOlder);


// typeof operator
console.log(typeof RajatOlder);
console.log(typeof ageRajat);
console.log(typeof 'Mark is older tha Rajat');
var x;
console.log(typeof x);
*/



/*****************************
* Operator precedence
*/
/*
var now = 2020;
var yearRajat = 1989;
var fullAge = 18;

// Multiple operators
var isFullAge = now - yearRajat >= fullAge; // true
console.log(isFullAge);

// Grouping
var ageRajat = now - yearRajat;
var ageMark = 35;
var average = (ageRajat + ageMark) / 2;
console.log(average);

// Multiple assignments
var x, y;
x = y = (3 + 5) * 4 - 6; // 8 * 4 - 6 // 32 - 6 // 26
console.log(x, y);


// More operators
x *= 2;
console.log(x);
x += 10;
console.log(x);
x--;
console.log(x);
*/
Please follow and like us:

0 Comments

Leave a Reply

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

RSS
Follow by Email