JavaScript is a "Just In Time" compiled language Which was made by Brendon Eich in 1995 At that time it was known as "Mocha" And JavaScript is designated as the world's most popular programming language There's a JavaScript engine in every browser which is responsible for running the JavaScript in that particular browser
JavaScript is like one of the World Wide Web technologies, for example, HTML and CSS Webpages used to be static before JavaScript came into existence
But when JavaScript is introduced in any website, client-side logic is enabled. And users can interact with those websites very effectively. Over 90% of the websites use JavaScript on the client site's JS History.
Before JavaScript came into existence, websites were static
And Brendan Eich realized that. It was really important to introduce a language like JavaScript on the client sites of the browser. That's why he started working on JavaScript, along with Netscape.
In 1995, there was a browser war going on which included Microsoft and Netscape. Netscape is used to tell the users to use the Netscape Navigator. And as usual, Microsoft used to tell the users to use Internet Explorer. Anyhow Internet Explorer became so infamous that Microsoft had to develop "Edge" for the users.
There were allegations that Microsoft had reverse-engineered Netscape and started working on a standard named "J Script" But in 1997. The first version of ECMA was released. ECMA is a standard that ensures that during all the runtimes of JavaScript, The behavior of JavaScript remains predictable. This ensures that the same JavaScript code, in different browsers, behaves in a very similar manner Extension of JavaScript can be {.js}, {.mjs} as well as {.cjs} JavaScript was named "Live Script" in its Beta release but finally. It was named JavaScript, One of the reasons for this was, Netscape was one of the greatest supporters of JavaScript. And for the sake of marketing Java, Netscape named this language as "JavaScript", Java was a trending programming language at that time. Therefore Brendan Eich used to think that it was the marketing ploy of Netscape. That they are naming the language "JavaScript" in reference to a very popular programming language "Java", But finally it was named "JavaScript". And till date, it still confuses the programmers.
Java and JavaScript are totally different programming languages, In 2009, an amazing thing happened Ryan Dahl introduced the V8 engine of Chrome, which was a JavaScript engine, into a C++ program. Then it became possible to run JavaScript, even outside of browser and client sites. That is how Node.js was established and Node.js became a very popular runtime. Similar to this runtime, JavaScript can be run in many other runtimes, outside of a browser. Because of this, people started using JavaScript outside of the browser.
Till 2018, millions of users started using Node.js, Not just that, the "Node Package Manager" of Node.js holds the maximum number of packages in this world. In 2015, a new version of JavaScript was introduced which was a major change.
It was known as ES6, And a lot of major syntactical changes were introduced in this language. Some of them were: 1. ES6 modules; 2. Iterators; 3. For of Loops; 4. Python style generators; 5. Let and Const Keywords; 6. Promises; 7. Template Literals, and so on. So this was about the history of JavaScript, now let's move towards the syntax.
JS Syntax let's learn about the syntax of JavaScript in more detail.
Console, Console has been provided in the JavaScript programming to lock the JavaScript in the browsers Errors, warnings, and custom messages of JavaScript are printed inside the Console. To print anything inside the Console of a browser, you can use "console.log()".
Comments
Comment's are the text which is not parsed through JavaScript, Which means a valid code is not accepted by JavaScript. The syntax to write a Single Line Comment in JavaScript is somewhat like this, And to write a Multi-Line Comment, the syntax is somewhat like this.
Variables in JS.
You can declare a Variable using the keywords "Var", "Let" and "Const", If you are using the "Var" keyword then you can redeclare and change the Variables. If you use the "Let" keyword then you cannot redeclare the Variable. But you can update the variable like "Var", But if you are using the "Cont" keyword then that is a constant You can neither update the variable nor declare the variable. One more difference between Let and Var is that, the value of the variable initialized using "Var" is undefined. But the value of the variable initialized using "Let" is not undefined.
Arithmetic Operators in JS, You can use the Arithmetic Operators in JavaScript in this way
Data Types in JS. There are two types of Data in JavaScript programming
1. Primitve values and;
2. Objects
Primitive values are those immutable data which is at the lowest level of this language. There are seven types of Primitive Datatypes in JavaScript that are present on your computer screen.
JS Objects
You can make objects in JavaScript, In which you can write the key-value pairs. And syntax to access the keys in the object is somewhat like this. You can also change an object using syntax just like this one. And you can also print an object using a syntax just like this one. You can also make Nested Objects which means you can put an object, inside an object, using a syntax like this one
Conditional Statements
You can use "If Else Conditionals" in JavaScript, You can put a condition inside "If" which is either true or false. If the condition is true, the code inside "If" will be executed, And if the condition is false, the code inside "Else" will be executed. The syntax to write "If-Else" is somewhat like this. You can write an "If-Else Ladder" in JavaScript in this way.
Switch Case Statements
JavaScript also includes "Switch Case Statements" which are similar to conditionals. This helps in running a few cases which are based on the values of variables. The syntax of Switch Case in JavaScript is somewhat like this.
Loops
There are many types of Loops in JavaScript
1. For Loops;
2. For Each Loop;
3. For Of Loops;
4. Do While Loops;
5. While Loops,
The syntax for "For Loops" is somewhat like this,
The syntax for "For Each Loop" is somewhat like this,
And the syntax for "For of Loops", in JavaScript, is somewhat like this.
"While Loops" in JavaScript can be made in this way And "Do While Loop " in JavaScript can be written in this way. To separate your logic in JavaScript, you can write "Functions" using syntax in this way.
Functions in JS You can call these Functions in this way. There is a concept of "Arrow Function" in JavaScript. According to this, you can write the Functions, in JavaScript, in this way. This function includes a very convenient syntax. Along with this, there are some more differences between Arrow Function and Normal JavaScript Function Events in JS
JavaScript also includes "Events" which you can listen to Like when a user clicks on an element or any user-defined custom event is fired. You can write a code in JavaScript that will be executed. You can see in this code when you click the button it will print "Happy Birthday" on the console Strings. You can make "Strings" in JavaScript using this syntax.
The important methods and uses of "String", are present on your screen. Using Template Literals in JavaScript, you can embed variables in a string. Template Literals. The syntax of Template Literals is somewhat like this. You can see here that you can print the variables directly into the string. There are a few methods of "Numbers" in JavaScript, which are present on your screen.
Arrays You can use "Array" to make a collection of elements in JavaScript And its syntax is somewhat like this Few important methods of Array are present on your screen "Date Object" in JavaScript helps you to represent the date Date Object You can use the Date Object in this way
type of Operator. Using the Type of Operators you can get to know the type of any variable. The syntax of Type of Operators if somewhat like this. Hoisting in JS, There is a concept of "Hosting" in JavaScript. In which the interpreter moves the Variables, Classes, and Functions to the top of the Code. This work is done by the interpreter before the code is executed.
OOPS in JS:
JavaScript is an object-oriented programming language. And you can make the "Classes" in JavaScript in this way. In this way, you can invoke the constructor. And in this way, you can perform inheritance in JavaScript. There is a "THIS" keyword in JavaScript. Which is used to refer to the current object, If you write "This. Something" inside a class, "This" refers to the object that is being made
So this was the syntax of JavaScript
I hope you have learned a lot about JavaScript from this article
I have made a lot of courses on JavaScript on this Website and with that.
That's all for this article guys!
0 Comments