All functions in JavaScript are called First class citizens

Higher order functions - functions that take in functions as arguments or return functions

Syntax

// Tutorials

// console.log('Hello World');

// // variables
// // let name = "Vinit";
// console.log(name);

// let firstName = "Vinit";
// let lastName = "Jahagirdar";

// console.log(firstName + " " + lastName)

// const interestRate = 0.3;
// // interestRate = 1;
// console.log(interestRate)

// Primitive data types
// let name = "Vinit"; //String literal
// let age = 23; // Number literal
// let isApproved = false; // Boolean literal
// let firstName = undefined;
// let selectColor = null;

// Referenece types: 
// Object
// Array
// Function

//object 
let person = {
    name: 'Mosh',
    age: 30
};

console.log(person)
console.log(typeof (person))
console.log(person)

let selection = 'name';
person[selection] = 'Mary'
console.log(person.name)

// Arrays
let selectedColors = ['red', 'blue'];
console.log(selectedColors);
selectedColors[2] = 'green';
console.log(selectedColors.)
console.log(selectedColors[0]);

// Function
function greet(name, lastname) {
    console.log("Hello" + ' ' + name + ' ' + lastname);
}

greet('John', 'Altman');
greet('Mary', 'Newman');

function square(number) {
    return number * number;
}

console.log(square(29));

console.log(100);
console.log(false);
console.log('Hello')

const x = 100
console.log(x)
console.error('Alert');
console.warn('Warning');
console.table({name: 'Brad', email: '[email protected]'})

const styles = 'padding: 10 px; background-color: white; color: green;'
console.log('%cHello World!', styles)

// Multi word Formating for variable names
//firstName = camelCase
// first_name = underscore
// FirstName = PascalCase
// firstname = lowercase

// Re-assigning Variables
age = 31;
console.log(age);

let score;
score = 31;
console.log(score);
if (true){
    score = score + 1;
}
console.log(score);

const x = 100;

const arr = [1, 2, 3, 4]
arr.push(5)
console.log(arr);

const person = {
    name: "Vinit",
};
console.log(person.name);
person.name = "Bin";
console.log(person.name);
person.email = '[email protected]';
console.log(person);

// Primitive data types:
// - String: Sequence of characters. Must be in quotes or backticks
// - Number: Integers as well as floating-point numbers
// - Boolean: Logical entity / true or false
// - Null: Intentional absence of any object value
// - Undefined: A Variable that has not yet been defined / assigned
// - Symbol: Built-in object whise constructor returns a unique symbol
// - BigInt: Numbers that are greater than the "Number" tyoe can handle

// String
const firstName = 'Sara';

// Boolean
const hasKids = true;

//Null 
const aptNumber = null;

//Undefined
// let score;
const score = undefined;

// Symbol 
const id = Symbol('id');

// BigInt
const n = 90023290290293290n;
const output = n;
console.log(output, typeof output);

// Reference types or Objects
// Arrays (Object)
const numbers = [1, 2, 3, 4];

const person = {
    name: 'Brad',
};

// Function aslo an object
function sayHello(){
    console.log('Hello');
}

const output = sayHello;

console.log(output, typeof output);

The Modern JavaScript Tutorial

Interaction - Alert, Prompt, confirm

**alert**shows a message.

**prompt**shows a message asking the user to input text. It returns the text or, if Cancel button or Esc is clicked, null.

**confirm**shows a message and waits for the user to press “OK” or “Cancel”. It returns true for OK and false for Cancel/Esc.

Data types

There are 8 basic data types in JavaScript.

The typeof operator allows us to see which type is stored in a variable.