Javascript Notes2
Javascript Notes2
geeksforgeeks
Courses
Tutorials
HTML/CSS
JavaScript
Sign In
GfG 160
Share Your Experiences
JavaScript Tutorial
JavaScript Basics
Introduction to JavaScript
JavaScript Versions
How to Add JavaScript in HTML Document?
JavaScript Syntax
JavaScript Output
JavaScript Comments
JS Variables & Datatypes
JS Operators
JS Statements
JS Loops
JS Perfomance & Debugging
JS Object
JS Function
JS Array
JS String
JS Numbers
JS Math
JS Map
JS Set
JS Objects
JS Advance
JavaScript Exercises
Full Stack DevelopmentCourse
Introduction to JavaScript
Last Updated : 21 Jan, 2025
JavaScript is a versatile, dynamically typed programming language used for
interactive web applications, supporting both client-side and server-side
development, and integrating seamlessly with HTML, CSS, and a rich standard
library.
<html>
<head></head>
<body>
<h1>Check the console for the message!</h1>
<script>
// This is our first JavaScript program
console.log("Hello, World!");
</script>
</body>
</html>
In this example
/*
This is a multi-line comment.
It can span several lines.
*/
console.log("Hello, World!"); // Prints Hello, World! to the console
In this example
Applications of JavaScript
Web Development: JavaScript adds interactivity and dynamic behavior to static
websites, with popular frameworks like AngularJS enhancing development.
Web Applications: JavaScript powers robust web applications, leveraging APIs,
React, and Electron to create dynamic user experiences like Google Maps.
Server Applications: Node.js brings JavaScript to the server side, enabling
powerful server applications and full-stack development.
Game Development: JavaScript, combined with HTML5 and libraries like Ease JS,
enables the creation of interactive games for the web.
Smartwatches: Pebble JS allows JavaScript to run on smartwatches, supporting apps
that require internet connectivity.
Limitations of JavaScript
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.
Why JavaScript is known as a lightweight programming language ?
JavaScript is considered a lightweight language due to its low CPU usage,
minimalist syntax, and ease of implementation. With no explicit data types and a
syntax similar to C++ and Java, it’s easy to learn and runs efficiently in
browsers. Unlike heavier languages like Dart or Java, JavaScript, especially with
Node.js, performs faster and uses fewer resources. While it has fewer built-in
libraries, this makes it more flexible, though external libraries are often needed
for advanced functionality. JavaScript’s efficiency and simplicity make it a top
choice for web development.
Regular Expression
try/catch
Exception Handling
switch case and do-while
ES4 ECMAScript 4 Abandoned due to conflicts
ES5 ECMAScript 5 2009
Added:
Object.values
Object.entries
Object.getOwnPropertiesDescriptors
ES9 ECMAScript 2018 2018
Added:
spread operator
rest parameters
ES10 ECMAScript 2019 2019
Added:
Array.flat()
Array.flatMap()
Array.sort is now stable
ES11 ECMAScript 2020 2020
Added:
String.replaceAll() Method
Promise.any() Method
ES13 ECMAScript 2022 2022
Added:
Top-level await
New class elements
Static block inside classes
ES14 ECMAScript 2023 2023
Added:
toSorted method
toReversed method
findLast, and findLastIndex methods on Array.prototype and TypedArray.prototypet
Note: Older versions of browsers do not support ES6.
To start your coding journey in JavaScript you can follow JavaScript Tutorial
Master DSA with JavaScript in just 90 days. Explore core DSA concepts, refine your
coding skills, and tackle real-world challenges. Take on the Three 90 Challenge—
complete 90% of the course in 90 days and earn a 90% refund as a reward for your
commitment!
Comment
More info