Training day 12 - JavaScript Basic to Beginners

Heloo people!!

Following notes:

//Comments are wriiten like this in JavaScript

Object syntaxlet person = { name: ‘abc’, age: 20 };

Dot Notation to access or change a property: person.name = ‘John’; console.log(person.name);

Bracket Notation person[‘name’]=‘Mary’;

Dynamicallylet selection = ‘name’; person[selection] = ‘Mary’;

Arrays let selectedColors = [‘red’, ‘blue’];

Functions function greet(name) { console.log(‘Hello ’ + name); } greet(‘Sahib’);

‘Sahib’ is an argument and name is a parameter.

Two Types of Functions:- User Defined

Then I learned about Operators.

Strict Equality (Type + Value) Console.log(1 === 1) //true console.log(‘1’ === 1)//false

Lose Equality (Value) console.log(1 == 1) //true console.log(‘1’ == 1) //true

false || true answer is true If we have false || ‘Sahib’ answer is ‘Sahib’

// Falsy (false) // undefined // null // 0 // false // ‘’ // NaN

// Anything that is not False is Truth

false || 1 || 2 When the operand is found that is truth, it is returned - no matter how many Truthy values are on the right. It is called shortcutting.

This can be used in a case like this:let userColor = undefined; let defaultColor = ‘blue’; let currentColor = userColor || defaultColor;

console.log(currentColor); //prints blue

I will continue the rest on Tuesday.

Byeee!