Different console methods in Javascript

Gagandeep Singh
There are few console methods available in Javascript, console.log being the most common one. Each of these variations of console methods could and should be used depending on type of data to output. console.log() - As mentioned earlier console.log() is the most common console method and can be used to output any kind of data. console.log(); const message = "Hello world"; const num1 = 10; const num2 = 20; console.

Structs in Go

Gagandeep Singh
Struct in Go allows to create custom data types. In the example below User is a struct type, it’s defined using the type keyword followed by the struct name and then struct. Struct can have once or more fields in it and fields are defined using name and type. For example: package main import "fmt" func main() { type User struct { firstname, lastname string age int } u1 := User{ firstname: "Gagandeep", lastname: "Singh", age: 32} fmt.

Create a globally executable javascript file

Gagandeep Singh
We will understand and see how to create an executable javascript file using a global command. Lets say for example you want to create a clone of ‘ls’ or ‘cmd’ command which shows the content of the current folder or from the path provided. To acheive that we need to have a global command. To acheive this we need to do couple of things and need to have 2 files (index.

Generics in Typescript

Gagandeep Singh
Tuples is a type that exists in Typescript which is similar to Array type but has fixed length and defined what kind of element (either same or different types) will be there at a certain position. // Array example const a: number[] = [1,2,3]; // Tuple example const t: [string, number, boolean] = ['2', 1, true]; Since Tuples are just arrays, so it will allow to push a new element only of type either string or number as defined in the tupleType below.

Tuples in Typescript

Gagandeep Singh
Tuples is a type that exists in Typescript which is similar to Array type but has fixed length and defined what kind of element (either same or different types) will be there at a certain position. // Array example const a: number[] = [1,2,3]; // Tuple example const t: [string, number, boolean] = ['2', 1, true]; Since Tuples are just arrays, so it will allow to push a new element only of type either string or number as defined in the TupleType below.