All You Need to know before coding
What is the JavaScript
JavaScript is a dynamic, just-in-time compiled, object-oriented programming language. JavaScript syntax implementation references C and Java. Brendan Eich, a Netscape engineer, created JavaScript in 1995. JavaScript is currently the most popular programming language in the world.
JavaScript is primarily used to develop Web-based applications. JavaScript is primarily used in Web-based applications and Web browsers. More than 97% of web sites use JS for web behavior on client pages. It is also used to add interactivity to websites, develop mobile applications, and create browser-based games.
JavaScript based
variable:
Variables are placeholders for information. It holds data values that can be changed at any time. Variables must have unique names. You can assign a value to a variable using equal (=) when you declare it or before you use it. There are three keywords in JavaScript to declare variables. You can declare variables like this:
varName = "Jhon Lenon"const age = 50
letProfession = "musician"Copy the code
Var: It is a function-scoped or global-scoped variable that can be selected to initialize to a value.
Const: The value of a constant cannot be changed by reassignment or redeclared.
Let: It is a block-scoped local variable that can be selected to initialize to a value. And variables declared by let can be reassigned.
object:
JavaScript is an object-oriented programming language. An object is a collection of properties. Attributes are associations between names and values. Object properties are written inside curly braces {}. Such as:
const person = {
Name: “Jhon Lenon”,
Age: 50.Profession: "Musician"}Copy the code
The data type:
There are not many data types in JavaScript compared to other languages. Here are the details of JavaScript data types:
The translator’s note:
In terms of how data is stored, JavaScript data types fall into two broad categories: basic data types (stored on the stack) and reference data types (stored on the heap)
According to the latest standard of ES, JavaScript, there are seven basic data types, respectively, Number, String, Undefined, Null, Object, Symbol, Bigint
JavaScript reference data types include Object, Function, Map, Set, and Array……
- Numbers: JavaScript numbers can be written without quotes. You can work with integers and floating point numbers. The basic operators handle numbers. Such as:
const number = 40;
const number = 40.20;
Copy the code
- String: A String is a text variable. Strings can be written in quotes. There are three types of creating strings. They are:
constPerson1 = "Jhon Lenon";constPerson2 = 'Steve Jobs';const person3 = `Bill Gates`;
Copy the code
-
Boolean: A Boolean is a logical data type. Booleans can have two values: true or false. It is used with conditional statements.
-
Null: The value Null indicates that there is no object value intentionally.
-
Undefined: Undefined indicates that the value has not been assigned.
-
Functions (Functions provides) :
Functions are one of the basic building blocks of JavaScript. Values can be passed to functions, and JavaScript always returns values
const x=myFunction(4.3); function myFunction(a,b){ return a*b; } Copy the code
-
Conditionals: JavaScript supports conditional statements that perform different actions based on different conditions. The conditions are if, else, and else if. JavaScript conditions are the most useful.
const isPlaying = true; if(isPlaying) {} "Playing"else{ “Not Playing” }; Copy the code
-
Loops: Loops are Loops that execute the same block of code over and over again, loop for as long as a certain condition is met. JavaScript has five types of loops:
While,
Do the while,
For,
, For… in
, For… of
constFruits = [" Apple ", "Banana", "Mango", "Orange", "Papaya"].for(var i=0; i<fruits.length; i++) { document.write("<p>" + fruits[i] + "</p>"); } Copy the code
-
Operators
JavaScript includes operators found in other languages. Operators perform certain operations on one or more operands (data values) and produce results.