JavaScript Notes..
Q.1: What is JavaScript?
Ans:- There are two types of scripting language on the web.
Client Side Script: - क्लाइंट साइड स्क्रिप्टिंग आपके फोन या डेस्कटॉप पर जावास्क्रिप्ट जैसे कोड चलाती है जबकि सर्वर-साइड स्क्रिप्टिंग बैक-एंड सर्वर पर चलती है। इस तरह, यह क्लाइंट डिवाइस के जवाब में वेब पेजों पर गतिशील सामग्री वितरित कर सकता है।
Server Side Script: - वेब डेवलपमेंट में उपयोग की जाने वाली एक तकनीक है जिसमें वेब सर्वर पर स्क्रिप्ट को नियोजित करना शामिल है जो वेबसाइट के लिए प्रत्येक उपयोगकर्ता (क्लाइंट) के अनुरोध के लिए अनुकूलित प्रतिक्रिया उत्पन्न करता है।
Uses of Js language on the web.
Ans: - This was an event-based language. Like (as click, keypress, Double-click, Key-up, Mouse-over, Load,.......) etc.
Benefits of JavaScript.
Ans: - By using the JavaScript language we can create an interactive webpage and add some functionality to web pages.
Frameworks of Javascript.
JQUARY
ANGULAR JS
REACT JS
VUE JS
NODE JS
These frameworks are used in web development.
Mobile App development.
ANGULAR JS
REACT JS
VUE JS
REACT NATIVE
NODE JS
Node Js also work on server-side scripting languages.
Q.2: How to implement JS in HTML pages.
Ans:- These are two ways to implement JS in an HTML page.
InPage JavaScript
External JavaScript
This was the example to Implement the InPage javascript.
Now see the external js link process 👇
Here we are using our external file name with the extension.js
Q.3: Comments in javascript.
Ans:- Comments play an important role in any programing language.If a developer wants to describe the written code heading then he/she uses comments in JS. let's see with an example...
The syntax was to declare a comment //
There were two types of comments in javascript.
Single line Comments: -
//
Multiple line Comments:-
/*........*/
Q.4: what are Variables in javascript?
Ans: - To store a code line into a small word with a name that's called a variable declaration. let's see with an example.
In this image, we saw a line like let value = 50;
the value word is called a variable name and the 50 is called a value that was assigned in a variable.
There are two ways to declare a variable name.
Right Way:-
first_name
first-name
firstName
firstname123
Wrong way:-
first name
123firstname
Q.5: Difference between VAR, LET, and CONST.
Var
: - If we have two variables and both have the same name then invar
, when we print the value var, gave us the 2nd variable name value. There was no error in printing the value.Let
: - If we have two variables and both have the same name then inLet
when we print the value Let gives an error to us.Const
: - Const has a simple meaning that if we declare a variable as a const we can not change the value of the const variable.
Q.6: Datatypes in Javascript.
Variables | Description |
var x = "Hello" | String |
var x = 25 | Number |
var x = true/false | Boolean |
var x = ["Ram", "Shyam",25, true] | Array |
var x = {first: "ram", last: "Shyam"} | Object |
var x = " " | undefined |
var x = null | Null |
Q.7: Arithmetic Operators.
Operators | Description |
+ | Addition |
- | Subtraction |
* | Multiplication |
** | Exponentaition (Square) |
/ | Division |
% | Modules(Reminder) |
++ | Increment |
-- | Decrement |
Q.8 Assignment Operators.
Operators | Examples | Same As |
\= | x=y | x=y |
+= | x+=y | x=x+y |
-= | x-=y | x=x-y |
*= | x*=y | x=x*y |
/= | x/=y | x=x/y |
%= | x%=y | x=x%y |
**= | x**=y | x=x**y |
Q.9: Google Chrome console.
Ans: - The Google console is mainly used to show the errors of the codes which was written by developers. And if we want to do some testing and calculations then also we can use the Google console.
There are few syntaxes to print the values on the console. let's see👇
Console.log
- To print the data in the console.
Console.table
- To print object data into table form.Console.error
- To print an Error message into the console.Console. warn
- Print the warning into the console.Console. clear()
- To clear all the messages into the console.
Q.10: Comparision Operators
Operators | Description |
\== | Equal to |
\=== | Equal to and equal data types |
!= | Not Equal |
!== | Not equal value or not equal types |
> | Greater then |
< | Less than |
>= | Greater than or equal to |
<= | less than or Equal to |
Q.11: If Statement.
Ans. This statement has two conditions which was that if we check any variable's value with other numbers and other values then we can use a conditional statement. The If statement execute when a condition is true.
Syntex:
if(condition){
// statement
}
let's see with an example👇
Q.12: Logical Operators.
Operators | Name | ||
&& | logical AND | ||
Logical OR | |||
! | logical NOT |
logical AND
- If both the conditions are true then the statement will run.logical OR
- If any One conditions are true the statement will run.logical NOT
- It runs into a reverse order if the condition is true then the operator gave false and if the condition is false then the operator gives true.
And operators example👆
OR operators example👆
Q.13: If Else conditions.
Ans. In the if section, we check the condition when the condition is true then the value is printed (code run). And if the condition is false then we can put any message into the else part to print into the console and others.
Syntex:
if(condition){
// Statement...
}else{
// Message to console...
}
let's see an example👇
Q.14: If else If statement
Ans. In this statement, the code runs stepwise if the condition is false in the first pieces of code then the condition checks in the else if statement and if the condition is also false in the block of code then the condition moves to the next else if.
syntax:
if(condition){
// statement
}else if{
//statement
}else if{
//statement
}......
else{
}
Let's see with an example👇