Introduction to JavaScript
Introduction to JavaScript
In this example
The<script> tag is used to include JavaScript code inside an HTML
document.
console.log() prints messages to the browser’s developer console.
Open the browser console to see the “Hello, World!” message.
“Hello World” Program in Server Console
/*
This is a multi-line comment.
It can span several lines.
*/
console.log("Hello, World!"); // Prints Hello, World! to the
console
Limitations of JavaScript
Despite its power, JavaScript has some limitations to consider:
Security Risks : JavaScript can be used for attacks like Cross-Site
Scripting (XSS), where malicious scripts are injected into a website
to steal data by exploiting elements like <img>, <object>, or <script>
tags.
Performance : JavaScript is slower than traditional languages for
complex tasks, but for simple tasks in a browser, performance is
usually not a major issue.
Complexity : To write advanced JavaScript, programmers need to
understand core programming concepts, objects, and both client-
and server-side scripting, which can be challenging.
Weak Error Handling and Type Checking : JavaScript is weakly
typed, meaning variables don’t require explicit types. This can lead
to issues as type checking is not strictly enforced.
JavaScript Versions
Let’s take a look at the different versions of ECMAScript, their release
years, and the key features they introduced
Versio Releas
n Name e Year Features
ECMAScrip
ES1 t1 1997 Initial Release
ECMAScrip
ES2 t2 1998 Minor Editorial Changes
Added:
Regular Expression
try/catch
ECMAScrip Exception Handling
ES3 t3 1999
switch case and do-while
ECMAScrip
ES4 t4 Abandoned due to conflicts
Added:
JavaScript “strict mode”
ECMAScrip JSON support
ES5 t5 2009
JS getters and setters
Added:
let and const
Class declaration
import and export
ECMAScript for..of loop
ES6 2015 2015
Arrow functions
Added:
Block scope for variable
async/await
ECMAScrip Array.includes function
ES7 t 2016 2016
Exponentiation Operator
Added:
Object.values
Object.entries
ECMAScrip
ES8 t 2017 2017 Object.getOwnPropertiesDescripto
rs
Added:
ECMAScrip spread operator
ES9 t 2018 2018
rest parameters
Added:
Array.flat()
ECMAScrip Array.flatMap()
ES10 t 2019 2019
Array.sort is now stable
Added:
ECMAScrip BigInt primitive type
ES11 t 2020 2020
nullish coalescing operator
Added:
ECMAScrip String.replaceAll() Method
ES12 t 2021 2021
Promise.any() Method
Added:
Top-level await
ECMAScrip New class elements
ES13 t 2022 2022
Static block inside classes
Added:
toSorted method
toReversed method