Hey there, Thanks for visiting this repository. In this repository, I'm writing simplified explanations, on almost every topic within JavaScript. Any beginner can utilize it to master JavaScript. This repository is created with the perspective of providing a solution to avoid the need for making notes while learning JavaScript. Don't forget to give this repository a star. I bet, if you bookmark this repo, you'll never have to make JS notes again.
JavaScript is an interpreted programming language that is used in Website Development, Mobile App Development, Desktop App Development, etc. But here we're talking about JavaScript for web development or precisely front-end web development so here is the revised definition:
Revised Definition: "JavaScript is a client-side (runs in the browser) scripting language that is used to add interactivity to a web page. For example, when the user clicks the button a pop-up message should appear or something else should happen. This kind of action-reaction behavior can be added to the website using JavaScript."
99% of websites use JavaScript on the client side for webpage behavior. - Wikipedia
Every browser has an embedded JavaScript engine that executes the JavaScript code.
"A JavaScript engine is a software component that executes JavaScript code, and every major browser has one." - Wikipedia
To include and write JavaScript alongside HTML and CSS there are 03 ways:
- Inline JavaScript.
- Internal JavaScript.
- External JavaScript.
For now, we will discuss the Internal and External JavaScript, and later in the chapters, we'll have a look at Inline JavaScript.
Writing internal JavaScript is similar to writing internal CSS. In CSS, we use the style tag, while in JavaScript, we use the script tag. The placement of these tags also differs: the style tag is placed just before the closing of the head section, whereas the script tag is usually placed just before the closing of the body tag. See the example below:
It is similar to external CSS. For CSS, a separate file with a .css extension is created and then linked to the HTML file using the link tag. Similarly, for JavaScript, a separate file with a .js extension is created and linked to the HTML file using the script tag. See the example below:
In this chapter, we will discuss the basics of programming and implement them using JavaScript.
A variable is like a container that is used to store some value or data. It can only store one value at a time. In different programming languages, variables are made differently, let's see how to make a variable in JavaScript:
Important Terms:
- Declaration/Defining: Creation of a variable.
- Assigning/Initializing: Giving value to the variable for the first time.
- Reassigning: Changing the value stored in the variable.
There are 03 ways to declare a variable in JavaScript, here are all of them:
Variables created with var, let and const are not the same some major differences are listed below: