Sign in

Javascript Concepts …

Before going into details let’s know what is Javascript?
Some also call it JS. And many may find it as an extension of Java.
Well that not true. Javascript is at first a programming language.

This is such a language that is profoundly used in web applications and makes them interactive. Well in addition to that we can say when a plant doesn’t get water for many days it becomes very dry but if it is given water then it really gets back its life. Similarly, we can say the HTML and CSS being the dry plant that needs Javascript for its flourishment and being green again in other words to make a website interactive then Javascript is a must.

And another misconception is that it is not an extension of java rather the thing is that it is a scripting language when it came out java was very popular so the name came as javascript. And if we say for similarities the implementation of OOP [Object Oriented Programming] is the biggest match of the bunch.

As a programming language, JS is very popular as the usage of telecommunication and the internet has been a burst and everything must have a web version of it. So Javascript must have the tools that can fix our problems, share our thoughts, and do as we like…

Well, Javascript works with a lot of data types like string, number, boolean, array, and so on. Being a basic conceptual blog I won’t talk about the hard parts rather quite simple ones…

Starting with strings.

Strings are nothing but we can easily explain as words. It may be a letter, maybe a single word[may or may not be meaningful], maybe many words, or even a sentence. In a simple sense when we are working with words we mean to work with strings. Mainly we cover a string by quotations [ ‘ ’ or “ ” ].

let message1 = "this is a string that can be changed because of let";
console.log(message1);
const message2 = "this is a string that can not be changed because of const";
console.log(message2);

  1. Making a string all uppercase
    There may come times when we have to make all the letters of the string uppercase. Then we will use a method called toUpperCase() that will uppercase the total string. A question may arise if there is a number in between then what will be the case. Well just do it in the console. It will uppercase only the letters, not the numbers or other symbols.
    let message1 = "this is a string that can be changed because of let";
    console.log(message1.toUpperCase());

Much about string now let's talk something on numbers, shall we?

  1. Generating number from string
    Suppose we have a string that contains a number but because of the “ ” quotations we cannot perform tasks like we can on a number so is there any way to convert that string to a number? Yes, the parseInt() or parseFloat() method does the trick.
    let a = '123.23';
    console.log(parseInt(a));
    console.log(parseFloat(a));

    I hope you got the point when to use parseFloat and when parseInt. Well to just add when you don’t want the decimal points then go for parseInt() and when the fraction points are needed then use parseFloat()

Well, I think these are quite basic stuff that we learned today. And I hope we could understand the use cases.

Hope to meet you lovely people soon.

Till then its goodbye from your friend,

shadreza

Hello beautiful people of the internet. Hope to share nice stuff with you...