Summery about 6 Days of JavaScript

Serajur Reza Chowdhury
6 min readMay 3, 2020

--

Day 1

String Methods

First you need to go through the string methods.

For string you can go through this methods.

charAt, concat, includes, endsWith, indexOf, lastIndexOf, replace, slice, split, startsWith, substr, toLowercase, toUppercase, trim, trimStart, trimEnd.

charAt() returns the index of the character. concat() adds a string with another string. Includes() checks whether a string is available from another string. endsWith() checks whether a string is available at the end of a string. indexOf() and lastindexOf() checks the first and last occurring index of a string of another string.

replace() replaces an expression or string with another string in a string. slice() slices a string from the beginning or specified index to end or the specified index. split() splits a string based on a specific delimeter and returns it in an array.

startsWith() checks whether a string is available at the start of a string. subStr() returns a portion of string from a specific index of a specific length. toLowerCase() and toUpperCase() makes a string cases all lower and upper respectively. trim() removes unneccssary spaces from both ends of a string. trimStart() does for the starting poing. trimEnd() does it for the ending point.

Numbers

IsNan is a number method which checks whether any number class expression is number or not. parseFloat() and parseInt() makes an expression a floating and integer number.

Object

create() creates and returns an object. assign() assigns properties from one object to another. freeze() and seal() stops object overwriting but seal() allows overwriting existing properties to the object. keys() and values() returns all the keys and values of an object inside an array.

Math

abs() returns the non-negative value. sin() and cos() returns values sine and cosine, taking radian parameters. exp() and log() returns the exponential and natural logarithm value. floor() takes an integer and returns highest closest integer less than a decimal number. random() returns a random floating point from 0 to 1. round() returns the value of a number rounded to the nearest integer. sqrt() returns the square root of a number. Takes an integer as argument. min() and max() returns minimum and maximum value of a set of numbers.

Array

concat() adds one or more arrays to another array. every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value. filter() filters an array based on provided function. find() does same but finds the first element that satisfies the function. pop() push() removes and adds elements from the back of the array. shift() and unshift() do it from the start. forEach() and map() goes through every element in an array. reverse() reverses an array. sort() sorts an array. splice() adds and removes elements from an array at the same time.

Day 2

Basics of JavaScript

JavaScript has the following data types

• Number

• String

• Boolean

• Symbol (new in ES2015)

• Object

• Function

• Array

• Date

• RegExp

• null

• undefined

There are 3 ways to declare a JavaScript variable, var, let, const. var works everywhere, let and const works inside scope. Let is mutable but const isn’t.

Like other languages, it has control statements.

JavaScript is an object oriented programming language. We can create objects with or without creating instances. We can access objects like an array.

We can create object with instance using the new keyword.

Static fields and methods can be accessed without creating an object instance. Instance fields and methods can be accessed using the object instance.

Storage and Browser Testing

All web apps may not run all browsers because of bugs, features. So, all web apps should be tested by running on browsers.

Client side storage helps to get better service from websites for the users.

Day 3

Comments

Comments are used to what a function or class do. We can use both one line or multi line comments for this.

Error

Error can stop a program. To stop it we will use try catch finally. try holds suspicious code that can generate error. If an error is caught then it is send to catch block. Finally is optional, we can run any code after catch in finally.

We can also rethrow error from catch block.

We can also create custom error extending Error

DOM

DOM is a tree like structure that renders html to the browser. We can access them by using child, siblings, parents etc.

Dom Nodes are simple html elements.

InnerHTML gives the text inside an html tag. Outerhtml returns the full html element.

DOM properties are like object properties. We can have html built-in and custom attributes.

We can insert, delete elements and modify html code using dom.

Day 4

There are two types of equality operators (==) and (===). The first one compares two expressions by forcefully changing types. The other checks normally.

Two ways we can get data type. One is typeof and the other is Object.prototype.toString().

instanceof checks whether a property is an instance of a constructor. This works only for custom made objects.

Eval evaluates strings.

All variables are by default undefined. Delete keyword is used to delete properties from object.

setTimeOut is used to run callback function after a specific time. setInterval runs callback function after specific interval.

Scopes are accessible range of a variable. Namespace is working space of a named variable in JavaScript. Two variables with same name causes clash in the same scope.

Hoisting is automatically declaring a var delared variable at the top of a function.

Day 5

Block binding is defines the workspace for a loop. var is accessible outside the block, where let and const is not.

const once declared cannot be modified. However for object const can be modified as loop variable because it does not do any assignement.

Parameters

We can set default values inside function parameters. Here, value gets assigned with let.

All arguments we pass gets stored in arguments array like object. Parameters and arguments number may not be same every time. Extra parameters will be declared as undefined.

Arrow Functions

Functions also get hoisted like var declared variables.

Arrow functions are functions that are declared with an arrow (=>) sign. It does not have any this binding.

Destructuring

Object destructuring is getting an object key’s value by putting it inside object literal.

While destructuring variable should be initialized, otherwise it will throw error.

We can also assign default and customized variable.

Same way we can do array destructuring. We also set an array while destructuring.

We can do nested object and array destructuring.

Classes

Before classes functions are used to be the class-like structure. Classes have different features like it is declared like let variable. Properties need to be assigned with Object.defineProperty(). By default they are use strict. Classes must call a constructor to create instance.

Classes can be first class citizens, which means classes can be send as parameters.

We can set a method name to a variable and set it as a method name.

Day 6

Inheritance

Inheritance lets you create a new class by extending an existing class with additional properties. The extended class inherits all the properties from the parent class. If the parent class is modified then the child have an access to the changes.

Encapsulation

Encapsulation prevents access to data except through the object’s functions. Using this objects can hide their data and prevent other objects from accessing the data directly.

get — the get keyword will bind an object property to a function. When a getter is called it returns a specific data.

set — the set keyword binds a property to an object by setting its value. When a setter is called it sets a value to a specific property.

this — this keyword refers to the object the properties belong to.

Polymorphism

When a class derives from another class, the derived class owns all the properties of the parent class. If both classes have same methods Polymorphism provides an ability to call the same method on different JavaScript objects.

Different Types of Function

Functions results depending on parameters or giving the same output known as pure function.

Function results giving different results in different times known as impure function.

Functions returning a function or taking a function as a parameter known as higher order function.

Recursion

Recursion is the process of calling a function inside itself until a condition is served. Once called it runs automatically till it satisfies a condition. It is widely used in algorithms and data structures.

Call Stack

Call stack is where a function is stored in an order for execution.

Blocking

While calling api, synchronous JavaScript takes the out the api calling function of the stack and store it in task queue and runs the rest of the code. Then after timeout it enters the stack using event loop.

--

--

Serajur Reza Chowdhury
Serajur Reza Chowdhury

Written by Serajur Reza Chowdhury

Software Engineer, curious JavaScript programmer, love to share concepts.

No responses yet