Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Thursday, May 15, 2025

React vs Angular vs Vue.js: A Modern Comparison of JavaScript Frameworks

JavaScript frameworks have transformed the landscape of modern web development, empowering developers to build dynamic, fast, and scalable web applications. Among the leading players in this space are React, Angular, and Vue.js—each bringing its own philosophy, strengths, and ecosystem to the table.

Before we dive into the feature comparisons, let’s take a brief look at the origin stories of these powerful frameworks.

Origins of the Big Three

React – Developed by Meta (Facebook)

Originally released in 2013 by Meta (formerly Facebook), React was created to improve the performance and scalability of Meta’s platforms, including Instagram and WhatsApp. Since its launch, React has become widely popular for its component-based architecture, excellent developer tools, and flexibility in building seamless web apps.

React is also the foundation of React Native, used for mobile development, and is continuously evolving under the stewardship of Meta.

Angular – Backed by Google

AngularJS made its debut in 2010, but it was completely reimagined as Angular in 2016, built on TypeScript, a syntactic superset of JavaScript.

Angular stands out for its rich ecosystem, modularity, and robust features like built-in routing and state management. With consistent updates from Google, Angular remains a go-to choice for building large-scale Single Page Applications (SPAs).

Vue.js – The Lightweight Champion

Vue.js was first introduced in 2014 and officially relaunched in 2016. Created by Evan You, a former Google developer who previously worked on AngularJS, Vue was designed to offer the best of both Angular and React—while keeping things simple and approachable.

Vue’s gentle learning curve, small bundle size, and separation of concerns (HTML, JS, CSS) make it particularly appealing for newcomers and experienced developers alike.

Strengths at a Glance

React: Fast, Flexible, and Backed by Meta

Straightforward Code Optimization: React simplifies code logic, helping teams build scalable applications faster.
Quick Loading Time: React enables faster rendering via Virtual DOM, crucial for SEO and user experience.
Powerful DevTools: Chrome and Firefox extensions offer deep insights and debugging capabilities.
Continuous Development: With Meta at the helm, React is always evolving with modern development needs.

Angular: Feature-Rich and Enterprise-Ready

Modularity: Angular breaks down large applications into modules for better organization and manageability.
Reusability: Clean, maintainable code makes it easier to reuse components and services.
Performance on a Budget: Angular delivers high performance without additional licensing costs.
Robust Built-in Features: Features like DOM sanitization, routing, and dependency injection come out-of-the-box.

Vue.js: Simplicity Meets Power

Size & Simplicity: Vue is lightweight and offers a clean, intuitive syntax, perfect for beginners.
Real-time Error Reporting: The ability to visualize the UI while coding helps catch and fix errors early.
Clear Code Separation: Vue supports separate blocks for JavaScript, templates, and styles, enhancing maintainability.

Final Thoughts

At the end of the day, there is no one-size-fits-all when it comes to choosing the best JavaScript framework. Your decision should be guided by:

The project scope and complexity

The skill level of your team

Your preference for performance>, flexibility, or simplicity

Whether it’s React’s speed, Angular’s robustness, or Vue’s simplicity, each framework brings something valuable to the table. Explore them, experiment, and choose the one that aligns best with your development vision.

Saturday, May 03, 2025

TypeScript vs JavaScript: What’s the Difference & Why It Matters

When it comes to web development, JavaScript is the undisputed veteran. But over the past few years, a new player has entered the scene and gained serious traction—TypeScript. You might’ve heard developers call it “JavaScript on steroids”, and honestly, that’s not far from the truth.

So, what’s the big deal about TypeScript? Is it worth switching from JavaScript? Or are both better together? Let’s explore.

Quick Overview: What Is TypeScript?

TypeScript is an open-source programming language developed by Anders Hejlsberg—the genius behind C#. It’s often described as “JavaScript for application-scale development,” and it lives up to that name. TypeScript is a superset of JavaScript, which means anything you can do in JavaScript, you can do in TypeScript—plus a whole lot more.

TypeScript adds features like:

  • Static typing

  • Object-oriented programming features

  • Compile-time checks

  • Interfaces and generics

In short, it’s designed to help developers build large, maintainable codebases without sacrificing the flexibility of JavaScript.

What Makes TypeScript Special?

Here’s why TypeScript stands out:

It's Still JavaScript (Under the Hood)

TypeScript builds directly on JavaScript’s foundations. You write TypeScript, compile it, and it turns into clean, browser-friendly JavaScript. That means you get all the benefits of TS without ditching your JS knowledge.

Seamless with Existing JavaScript Libraries

Once TypeScript is compiled into JavaScript, it can be used with any existing JS framework or library—React, Vue, Node.js, you name it. There’s no awkward learning curve or compatibility concern.

Runs Anywhere JavaScript Does

No special runtime, no virtual machines. TypeScript works wherever JavaScript works—whether it’s in the browser, on a server, or even in embedded systems.

JavaScript: The OG of the Web

Now, let’s not forget where it all started.

JavaScript is the original scripting language of the web. It powers the dynamic behavior on websites and enables everything from simple dropdowns to full-blown web apps. And today, it’s not just for browsers—thanks to platforms like Node.js, JavaScript is used for backend development, desktop apps, IoT, and more.

Why Developers Still Love JavaScript

Despite the rise of TypeScript, JavaScript remains a favorite for many reasons:

Super Flexible

JavaScript doesn’t box you in. Whether you’re building a simple webpage or a data-driven dashboard, JS adapts quickly.

Dynamic by Nature

Variables in JavaScript can change type on the fly, allowing for rapid prototyping and experimentation.

Cross-Platform Compatibility

It runs virtually everywhere—Windows, Mac, Linux, Android, iOS—you name it.

Lightweight & Efficient

JavaScript is resource-friendly, especially for mobile apps and embedded environments.

Interpreted Language

No compilation needed. Just write and run. This makes development fast and interactive, perfect for quick iterations.

Compatibility & Interoperability

Here’s the best part: TypeScript is fully compatible with JavaScript. That means you can gradually introduce TypeScript into your existing JS codebase without a full rewrite. It’s like upgrading your old reliable car with smart features—you don’t lose what works, but you gain a lot more control and efficiency.

Stay Ahead of the Curve

Whether you're just getting started with JavaScript or diving deep into TypeScript, one thing’s for sure: both languages have earned their place in modern development.

Monday, March 11, 2024

Convert String to Title case using Javascript

Here is the function to convert string to title case, which can handle spaces and underscores. Below function will remove underscores from the string.

// Import the function
function convertToTitleCase(input) {
  return input.toLowerCase().replace(/_/g, ' ').replace(/\b\w/g, function(match) {
    return match.toUpperCase();
  });
}

You can call the convertToTitleCase function in HTML by including a script tag with the function definition, and then using JavaScript to call the function and display the result.

Here's an example of how you can call the convertToTitleCase function in HTML:

<!DOCTYPE html>
<html>
<head>
  <title>Convert to Title Case</title>
</head>
<body>

<p id="output"></p>

<script>
// Function definition
function convertToTitleCase(input) {
  return input.toLowerCase().replace(/_/g, ' ').replace(/\b\w/g, function(match) {
    return match.toUpperCase();
  });
}

  // Call the function and display the result
  let input = "Nagasai_Srinivas_Mudara";
  let convertedString = convertToTitleCase(input);
  document.getElementById("output").innerHTML = convertedString;
</script>

</body>
</html>

In this JavaScript function, the replace method is used with a regular expression to match the underscores and lowercase letters and convert the lowercase letters to uppercase when preceded by an underscore or at the beginning of the string.

You can use the convertToTitleCase function to convert any input string to title case in a generic and reusable way.

Thursday, July 13, 2023

How to read JSON list from JavaScript

To read a list of JSON objects in JavaScript, you can use the JSON.parse() function to parse the JSON string into a JavaScript object or an array.

Here's an example:

var jsonString = '[{"name":"Maximus","age":30},{"name":"Peter Parker","age":25},{"name":"Bob Krammer","age":40}]';

// Parse the JSON string into an array of objects
var jsonArray = JSON.parse(jsonString);

// Iterate over the array and access the properties of each object
for (var i = 0; i < jsonArray.length; i++) {
  var obj = jsonArray[i];
  console.log("Name: " + obj.name + ", Age: " + obj.age);
}
  

In the above example, the jsonString variable holds a JSON string representing an array of objects. The JSON.parse() function is used to parse the JSON string into the jsonArray variable, which becomes an array of objects.

You can then iterate over this array and access the properties of each object as shown in the for loop.

Note that the JSON string should be well-formed, with double quotes around property names and string values.

Hope this helps!

Monday, May 28, 2018

“md-select” - How to set a selected option of a dropdown list control using angular JS?

Try this following code to set selected value based on selected index.

<div layout="row" flex layout-align="start">
	<md-input-container flex>
		<label>{{'TicketType_Label'| translate}}</label>
		<md-select ng-model="feedbackObj.ticketType"  ng-required="true" md-no-asterisk="false" >
			<md-option ng-selected="i == 0 ? true:false"  ng-repeat="(i,type) in TicketTypes" >{{type}}</md-option>
		</md-select>					
	</md-input-container>
</div>

Thursday, October 05, 2017

javascript - .includes() not working in Internet Explorer

includes is not supported in Internet Explorer (or Opera)

Instead you can use indexOf. #indexOf returns the index of the first character of the substring if it is in the string, otherwise it returns –1

or you can use below function to in your javascript and you can still use include to work in IE10 / IE11

//IE 10/IE11 fix for includes function
String.prototype.includes = function () {
    'use strict';
    return String.prototype.indexOf.apply(this, arguments) !== -1;
};

Hope this helps!

Sunday, August 28, 2016

Flip image via Javascript/CSS?

This is how image can be flipped, like a mirror image

<div id="container" class="flip-vertical">
<h3 class="flip-vertical">vertical flip</h3>
</div>

.flip-horizontal {
    -moz-transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
    -o-transform: scaleX(-1);
    transform: scaleX(-1);
    -ms-filter: fliph; /*IE*/
    filter: fliph;
}
.flip-vertical {
    -moz-transform: scaleY(-1);
    -webkit-transform: scaleY(-1);
    -o-transform: scaleY(-1);
    transform: scaleY(-1);
    -ms-filter: flipv; /*IE*/
    filter: flipv;
}

Sunday, June 05, 2016

Browser support and comparisons

Recently found a amazing site www.caiuse.com which is Useful to web designers/developers.

"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.

Very useful and I recommend this!

Tuesday, November 17, 2015

TextBox set to ReadOnly using javascript

Here is a quick solution that works across the all browsers. Add below code in input textbox.

onKeyPress = "javascript: return false;" onPaste = "javascript: return false;" .

That way, even the textbox is enabled, the user will not be able to modify the data

Thursday, September 11, 2014

How To Display Current Time on Page using Javascript

Here is the JavaScript function which will get current time in Military format.

<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('Showtime').innerHTML=h+":"+m+":"+s;
t=setTimeout(function(){startTime()},500);
}

function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>

Thursday, March 27, 2014

How to change or add script tag source from C#?

Here is how we can add script to page header from code behind in c#. The reason why I am doing this is I have these JavaScript files included in master page. And when I try to give path of these files I am getting issues with absolute page when I got to other pages since I have these in master page.

and one more reason why I did is I don’t want to change this every time if deploy to different environment from QA, Stage and Production.

This is how we can do it in your master page.

string js1 = HttpContext.Current.Request.ApplicationPath + "/Scripts/jquery.cycle2.js";
string js2 = HttpContext.Current.Request.ApplicationPath + "/Scripts/jquery.countdown.js";

Literal js1script = new Literal();
js1script.Text = string.Format(
@"<script src=""{0}"" type=""text/javascript""></script>", js1);
Page.Header.Controls.Add(js1script);

Literal js2script = new Literal();
js2script.Text = string.Format(
@"<script src=""{0}"" type=""text/javascript""></script>", js2);
Page.Header.Controls.Add(js2script);

Hope this is useful!!

Friday, January 10, 2014

How to hide all Validators from JavaScript in .NET?

Here is how you can hide all validator messages from below JavaScript.  

function HideValidators() {
if (window.Page_Validators)
for (var vI = 0; vI < Page_Validators.length; vI++) {
var vValidator = Page_Validators[vI];
vValidator.isvalid = true;
ValidatorUpdateDisplay(vValidator);
}
}

Tuesday, January 07, 2014

How to hide Validation controls from JavaScript in .NET?

Here is how you can hide validation summary using the below JavaScript.  Call this in your aspx page. This should do trick for you.

// Hiding all validation contorls  
for (i = 0; i < Page_Validators.length; i++) {
ValidatorEnable(Page_Validators[i], false)
}


It works in IE and Mozilla. Hope this helps

Thursday, October 24, 2013

How to hide Validation Summary from JavaScript in .NET?

Here is how you can hide validation summary using the below JavaScript.  Call this in your aspx page. This should do trick for you.

function HideValidationSummary(){

if (typeof(Page_ValidationSummaries)!= "undefined"){ //hide the validation summaries
for (sums = 0; sums < Page_ValidationSummaries.length; sums++) {
summary = Page_ValidationSummaries[sums];
summary.style.display = "none";
}
}

}

It works in IE and Mozilla. Hope this helps

 

Sunday, December 05, 2010

Javascript Tip: Close Pop-up - Refresh Parent

Sometimes we need to force parent refresh on closing pop-up window which was opened from this parent window. There are many ways to make it work, however the most elegant way will be using location.href

function Refresh() 
{
    window.opener.location.href = window.opener.location.href;
    window.close();
}

Smile

Tuesday, November 16, 2010

Help full Tools and Converters

Here are some useful tools and converters which are helpful for conversion and compression

.NET Code converters

You can translate any C# code to VB.NET and VB.NET to C#.

http://converter.telerik.com/

http://www.aspalliance.com/aldotnet/examples/translate.aspx

http://www.developerfusion.com/utilities/convertcsharptovb.aspx

I have used first URL from telerik. Its works just great

Compress your CSS

http://www.developerfusion.com/tools/compresscss/

Compress and obfuscate javascript

http://www.developerfusion.com/tools/compressjavascript/

Clear Browser History Through Javascript

If you need to clear the Browser History, after arriving on a particular page (e.g. arriving to Login page after Logout).

Here is the code to do this. If you put this code in Login page, it wont take it to be back page. You need to put this from where you do not want to move back. Here is the code snippet.

<script type="text/javascript">
        window.onload = function () { Clear(); }
        function Clear() {            
            var Backlen = history.length;
            if (Backlen > 0) history.go(-Backlen);
        }
</script>

if you do not want the user to move to the back page, you can do as below. This script needs to be repeated at where you don’t want to do this.

<script type="text/javascript">
       if(window.history.forward(1) != null)
           window.history.forward(1);
</script>

Hope this helps.

Monday, October 04, 2010

JavaScript: Display Clock

Displaying a clock is very similar to making a countdown timer. All we have to do is to create a new date and get it's hours, minutes, and seconds.

Here is a example:

<!-- This span is where the clock will appear -->
<div id='clockDiv'></div>
<script type="text/javascript">
function clock() {
   var now = new Date();
   var outStr = now.getHours()+':'+now.getMinutes()+':'+now.getSeconds();
   document.getElementById('clockDiv').innerHTML=outStr;
   setTimeout('clock()',1000);
}
clock();
</script>

Hope this helps :-)

JavaScript: Count down Timer

This is how creating Count down timer using JavaScript with Julian dates. This code below creates two Julian dates, now and newYear. By subtracting now from newYear we get an integer which represents the difference between the two dates.

Suppose you want to know your birthday in days, hours and minutes etc. This is how you can achieve using JavaScript.

<!-- This span is where the countdown timer will appear -->
<div id='countdown'></div>
<script type="text/javascript">
// Here's our countdown function.
function happyBirthDay() {
var now = new Date();
var newYear = new Date('October 20, '+(now.getFullYear()+1));
var diff=newYear-now;
var milliseconds=Math.floor(diff % 1000);   
    diff=diff/1000;            
var seconds=Math.floor(diff % 60);
    diff=diff/60;
var minutes=Math.floor(diff % 60);
    diff=diff/60;
var hours=Math.floor(diff % 24);
    diff=diff/24;
var days=Math.floor(diff);
// We'll build a display string instead of doing document.writeln
   var outStr = days + ' days, ' + hours+ ' hours, ' + minutes;
       outStr+= ' minutes, ' + seconds + ' seconds until your birthday!'; 
   // Insert our display string into the countdown span.
   document.getElementById('countdown').innerHTML=outStr;
   // call this function again in exactly 1 second.   
   setTimeout("happyBirthDay()",1000);
}
// call the countdown function (will start the timer)
happyBirthDay();   
</script>

Hope this helps!