FUNDAMENTALS  of Java Script-01

FUNDAMENTALS of Java Script-01

Presently I am learning the java script.instead of making the notes .I choose learning in the public .here my first blog on javascript

Fundamentals of JS

Js is the high level object oriented ,multi-paradigm programing language. It is object oriented because objects is used to storing the most kind of data. Js is real programing language of the web for building the web application There is nothing you can't do with java script[well almost] It is also used to built the native mobile application and desktop applications..

Now let us know about what are al the fundamentals required to understand and write the javascript core.

values and variables

It is the smallest basic information in the javascript it's called a values Example:

'Rahul' it's  a value.
'23' it's  a value.
Console.log("Rahul");
Console.log("23");

Consol.log(); it's a expression that value displayed on the console when we inspect the web page.

variable

Imagine variable is like a container or a box where we can store a value. So.that value can be used again and again with that variablename.

let firstName="rahul";
Const firstJob="programmer";
Console.log(firstName);
Console.log(firstJob);

Here rahul is a value which can be stored in the variable firstName And programmer is value which can be stored in a variable first job

rules for creating variable names

1)first letter of a variable name is always a small letter.

2)we can't write a variable name like let 3words=3; Numbers not allowed to create the variable name.

3) in between the variable name we cannot use any symbols expect underscore or dollor symbol

let_function=27;
let $name="basu";

These two symbols only allowed in contracting the variable name.

4) we shouldn't start with the uppercase.

5) variable should be descriptive.

primitive data types

data types in js.

Primitive data type means data types which cannot be broken down further

1) Number

2)Boolean

3)string

4)undefined

5)null

6)symbol(es2015)

7)bigint(es2020)

Out of these data type number, boolean,string data types are important.

Symbol data type used in the previous version of the js.symbol is a unique number. It cannot be changed.

Bigint is data type which is used in the modern version of the is.generally store larger integer than numbers.

1)Number

It consist of numbers. Like other programing language there is no integer,float,data type not there in java script. Whether it is integer floating points fall under number data types

let number1=23;
Const number2=77;
Console.log(number1);
Console.log(number2);

2)Boolean

It is data type which consists only two values

1)TRUE

2)FALSE

Const isEvenNumber="TRUE";
Console.log(isEvenNumber);

string

The data type which consist a set of characters

Const firstName="sidharth";
Console.log(firstName);

how to declare variables Basically 3 different ways to declare the variables

1)let

2)const

3)var

let

'Let'can be used to declare the variables. When we declare the variable using the 'let'the value of the variable can be further changed.

let firstJob='programmer ';
firstJob='teacher';
Console.log(firstJob);

Initially the value of the variable is programmer.then the value of variable changed to teacher.

It can be only possible when we declare the variable using 'let' Declare the variable using 'let'when we further want to change the value of variable

const

It is used to declare the variable . When we declare with 'const 'the value of the variable cannot be changed.

Const lastName="basu";
Console.log(lastName);

This variable always remain same. Unlike 'let'the value of the variable cannot be changed.

It is always better to declare the variable with 'const'instead of'let' In order to prevent the errors. If it's necessary then declare with 'let'.

Type conversion and Coercion

Type conversion: When you manually convert one data type into anthore data type

Const inputYear='2002';
Console.log(number(input year));
Console.log(inputyear+18);

Initially 2002 is string when we add with the 18 it gives output as 200218. But we want to add 18 with the inputyear so the string should be converted into number then only we get ans So that string can be converted into number like above.

Number also converted into the string

Const number=23;
Console.log(string(number));

coercion

Java script itself in the backend which convert data type.

Console.log('I am'+23+'year old');
Console.log('23'-'10'-3);

Behind the scene the javascript which convert 23 number into string.

  • this operator which convert string to number.

'-'this operator which convert number into string.

This is actually not done by manually but it is done by js.hence it is called type coercion.

Thanking you🙂..