Welcome to my blog !


How to Compare Enum strings or numbers in typescript with example

April 28, 2020 ·  2 min read

In this tutorial post, We are going to compare the String with Enum value in typescript/javascript The below examples uses the comparision operator !== and === operator for checking enum equality Compare Strings value exists in Enum of Typescript In the below example, Enum is declared for color pygmentsCodefencesGuessSyntax Enum contains a string property name and its value === operator is used to check string against with Enum Object. By default, triple equal operator applied of same two operands of the same type...

How to find length of enum data in javascript/typescript

April 27, 2020 ·  1 min read

Enum is inbuilt in data type used to store multiple contents in a single namespace. Sometimes, As a developer need to find number of elements of enum in javascript/typescript There is no inbuilt in method to find out the size of properties of an enum. lets declare enum constants in Javascript, The same code works in Typescript export enum Color { RED = "#FF0000", GREEN="#008000", YELLOW = "#FFFF00", BLUE="#0000FF", MAROON="#800000" } console....

Javascript tutorials - In operator examples

April 26, 2020 ·  3 min read

In operator is inbuilt operator provided in javascript language, This covers the usage of In operator in the following cases Contents Javascript In operator syntax Check valid index exists in an array using in operators Check property of an object in Javascript In operator enum Usage Check string exists in Enum typescript or Javascript Iterate Enum data Javascript In operator in operator in javascript used to find the property presents in an object....

How to populate enum data in HTML select/dropdown in angular material

April 25, 2020 ·  2 min read

We need to populate Enum values populated in the Select/dropdown of an angular application. Let declare enum type in typescript for this examples export enum Weeks { MONDAY = 1, TUESDAY= 2, WEDNESDAY = 3, THURSDAY = 4, FRIDAY = 5, SATURDAY= 6, SUNDAY= 7, } This post will talk you about how to populate enum string or numbers in HTML select of an angular application Angular material dropdown with enum datatype Html select with Enum values Angular Material dropdown based on enum values Install angular material npm in your applicaiton as described package....

How to iterate strings,values of an Enum type in javascript/typescript

April 24, 2020 ·  3 min read

Enum is an enumeration of names and values replacing multiple constants with a single namespace. There are many ways we can iterate enum data. This blog post covers the examples for looping the Enum string or numbers using different approaches Using Object inbuilt methods iterate An enum is also an object in javascript, Object class provides the following methods The Object.keys() method returns array of the keys of an object The Object....