Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Javascript Notes2

JavaScript is a versatile, dynamically typed programming language essential for web development, supporting both client-side and server-side applications. It features a rich ecosystem of libraries and frameworks, enabling interactivity and dynamic content on websites. The document also outlines JavaScript's key features, applications, limitations, and its evolution through various ECMAScript versions.

Uploaded by

Bharath
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Javascript Notes2

JavaScript is a versatile, dynamically typed programming language essential for web development, supporting both client-side and server-side applications. It features a rich ecosystem of libraries and frameworks, enabling interactivity and dynamic content on websites. The document also outlines JavaScript's key features, applications, limitations, and its evolution through various ECMAScript versions.

Uploaded by

Bharath
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

Skip to content

geeksforgeeks
Courses
Tutorials
HTML/CSS
JavaScript

Sign In

DSA with JS - Self Paced


JS Tutorial
JS Exercise
JS Interview Questions
JS Array
JS String
JS Course
JS Object
JS Operator
JS Date
JS Error
JS Projects
JS Set
JS Map
JS RegExp
JS Math
JS Number
JS Boolean
JS Examples
JS Free JS Course
JS A to Z Guide
JS Formatter

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.

JavaScript is a single-threaded language that executes one task at a time.


It is an Interpreted language which means it executes the code line by line.
The data type of the variable is decided at run-time in JavaScript that’s why it is
called dynamically typed.
“Hello, World!” Program in Browser Console
A “Hello, World!” program is the simplest way to get started with any programming
language. Here’s how you can write one using JavaScript.

<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

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.
To learn more about it follow the article – JavaScript Hello World

“Hello World” Program in Server Console


We can also print the “Hello World” program directly into the console terminal
without embedded it into HTML. Create an index.js file and add the code to it.

/*
This is a multi-line comment.
It can span several lines.
*/
console.log("Hello, World!"); // Prints Hello, World! to the console
In this example

console.log(): The console.log() method is used to print messages to the browser’s


developer console. Open the console (usually with F12 or Ctrl + Shift + J) to see
the message “Hello, World!” displayed.
Comments in the Code:
Multi-line Comment: The /* */ syntax is used to write a comment spanning multiple
lines.
Single-line Comment: The // syntax is used for short, inline comments, like the one
explaining the console.log function.
To learn more about comments follow the article – Comments in JavaScript
Key Features of JavaScript
Client-Side Scripting:JavaScript runs on the user’s browser, so has a faster
response time without needing to communicate with the server.
Versatile: JavaScript can be used for a wide range of tasks, from simple
calculations to complex server-side applications.
Event-Driven: JavaScript can respond to user actions (clicks, keystrokes) in real-
time.
Asynchronous: JavaScript can handle tasks like fetching data from servers without
freezing the user interface.
Rich Ecosystem: There are numerous libraries and frameworks built on JavaScript,
such as React, Angular, and Vue.js, which make development faster and more
efficient.
Client Side and Server Side nature of JavaScript
Client-side: Involves controlling the browser and its DOM, handling user events
like clicks and form inputs. Libraries such as AngularJS, ReactJS, and VueJS are
commonly used.
Server-side: Involves interacting with databases, manipulating files, and
generating responses. With Node.js and frameworks like Express.js, JavaScript is
also widely used on the server side.
Imperative Programming: Focuses on how to perform tasks, controlling the flow of
computation. It includes approaches like procedural and object-oriented
programming, often using constructs like async/await to handle actions.
Declarative Programming: Focuses on what should be done rather than how it’s done.
It emphasizes describing the desired result, like with arrow functions, without
detailing the steps to achieve it.
JavaScript-Introduction
JavaScript Introduction

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.

Is JavaScript Compiled or Interpreted or both ?


JavaScript is both compiled and interpreted. The V8 engine improves performance by
first interpreting code and then compiling frequently used functions for speed.
This makes JavaScript efficient for modern web apps. It’s mainly used for web
development but also works in other environments. You can learn it through
tutorials and examples.

Just-In-Time (JIT) compilation is a technique used by JavaScript engines (like V8)


to improve performance. Here’s how it works

Interpretation: Initially, the code is interpreted line-by-line by the engine.


Hot Code Detection: The engine identifies frequently executed code, such as often-
called functions.
Compilation: The “hot” code is compiled into optimized machine code for faster
execution.
Execution: The compiled machine code is then executed directly, improving
performance compared to repeated interpretation.
JIT compilation balances between interpretation (for quick startup) and compilation
(for faster execution).
JavaScript Versions
Let’s take a look at the different versions of ECMAScript, their release years, and
the key features they introduced

Version Name Release Year Features


ES1 ECMAScript 1 1997 Initial Release
ES2 ECMAScript 2 1998 Minor Editorial Changes
ES3 ECMAScript 3 1999
Added:

Regular Expression
try/catch
Exception Handling
switch case and do-while
ES4 ECMAScript 4 Abandoned due to conflicts
ES5 ECMAScript 5 2009
Added:

JavaScript “strict mode”


JSON support
JS getters and setters
ES6 ECMAScript 2015 2015
Added:

let and const


Class declaration
import and export
for..of loop
Arrow functions
ES7 ECMAScript 2016 2016
Added:

Block scope for variable


async/await
Array.includes function
Exponentiation Operator
ES8 ECMAScript 2017 2017
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:

BigInt primitive type


nullish coalescing operator
ES12 ECMAScript 2021 2021
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 learn more about it follow the article – JavaScript Versions

To start your coding journey in JavaScript you can follow JavaScript Tutorial

Variables and Data Types


Operators
Control Flow (Conditionals)
Loops
Functions
Objects and Arrays
DOM Manipulation
Events
Asynchronous JavaScript (Callbacks, Promises, Async/Await)
Scope and Closures
Strict Mode
Introduction to JavaScript – FAQs
What is JavaScript?
JavaScript is a high-level, dynamic programming language used to make web pages
interactive. It is a core technology of the World Wide Web, alongside HTML and CSS.

What is JavaScript used for ?


JavaScript is a versatile language used for web development, adding interactivity,
dynamic content, and user-friendly features like sliders, forms, and animations.
It’s also used in web apps, backend services (via Node.js), game development, and
mobile apps.

What is the difference between JavaScript and Java?


JavaScript and Java are distinct languages with different purposes. Java is an
object-oriented programming language for building standalone applications, while
JavaScript is primarily used to enhance web pages with interactivity and dynamic
content.

What is JavaScript DOM ?


The JavaScript DOM (Document Object Model) lets you interact with and manipulate
HTML and CSS. It represents a web page as a tree of objects, enabling real-time
updates, style changes, and event handling for dynamic, responsive pages.

How do you include JavaScript in an HTML document?


JavaScript can be included in an HTML document in three ways:

Inline, by placing it directly within HTML elements.


Internal, by placing it within a <script> tag in the HTML document.
External, by linking to a separate .js file using the <script
src=”filename.js”></script> tag.
What are variables in JavaScript?
Variables in JavaScript store data values. They can be declared using var, let, or
const.

What is Hoisting in JavaScript?


Hoisting in JavaScript refers to the behavior where variable and function
declarations are moved to the top of their containing scope during compilation.
However, only the declarations are hoisted, not the initializations, leading to
potential issues with uninitialized variables.

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

Placement Training Program


Next Article
JavaScript Versions
Similar Reads
Introduction to JavaScript Course - Learn how to build a task tracker using
JavaScript
This is an introductory course about JavaScript that will help you learn about the
basics of javascript, to begin with, the dynamic part of web development. You will
learn the basics like understanding code structures, loops, objects, etc. What this
course is about? In this course we will teach you about the basics of the scripting
language i.e) Ja
4 min read
Introduction to Object Oriented Programming in JavaScript
As JavaScript is widely used in Web Development, in this article we will explore
some of the Object Oriented mechanisms supported by JavaScript to get the most out
of it. Some of the common interview questions in JavaScript on OOPS include: How is
Object-Oriented Programming implemented in JavaScript? How does it differ from
other languages? Can yo
7 min read
Introduction to Javascript Engines
JavaScript is a scripting language and is not directly understood by computer but
the browsers have inbuilt JavaScript engine which help them to understand and
interpret JavaScript codes. These engines help to convert our JavaScript program
into computer-understandable language. A JavaScript engine is a computer program
that executes JavaScript co
4 min read
A Quick Introduction to pipe() and compose() in JavaScript
Functional programming is gaining popularity in JavaScript development. Two
fundamental concepts in functional programming are function composition and piping,
which are implemented using compose() and pipe() respectively. These concepts allow
for the creation of complex operations by combining simple functions in a clear and
readable manner. In th
3 min read
Introduction to Built-in Data Structures in JavaScript
JavaScript (JS) is the most popular lightweight, interpreted compiled programming
language, and might be your first preference for Client-side as well as Server-side
developments. Let's see what inbuilt data structures JavaScript offers us: Data
Structure Internal Implementation Static or Dynamic JavaScript Arrays Contiguous
Memory Allocation Dynam
2 min read
How can JavaScript codes be hidden from old browsers that do not support JavaScript
?
Nowadays all modern browsers support JavaScript, however, older browsers did not
support JavaScript. In this article, we will learn how we can hide JavaScript code
from running in older browsers. Approach: After opening the <script> tag, we will
use a one-line HTML style comment without any closing character ( <!-- ). We will
then write th
2 min read
How are the JavaScript window and JavaScript document different from one another?
What is a JavaScript window? The window is at a root/top level at the JavaScript
object hierarchy. It is a global/root object in JavaScript and it is the root
object of the Document object model(DOM); What is a JavaScript document? A document
is an object inside the window object and we use a document object for manipulation
inside the document. T
3 min read
Which href value should we use for JavaScript links, "#" or "javascript:void(0)" ?
In this article, we will know which "href" should be used for JavaScript when we
can use "#" or "javascript:void(0)". Let us understand it. Using the '#' value: The
# is a fragment identifier used to refer to a specific section of the same
document. When a user clicks a link with a # href, the browser will scroll to that
section of the page specifi
3 min read
How to Delay a JavaScript Function Call using JavaScript ?
Delaying a JavaScript function call involves postponing its execution for a
specified time using methods like setTimeout(). This technique is useful for timed
actions, animations, or asynchronous tasks, enabling smoother user experiences and
better control over when certain operations run.There are several ways to delay the
execution of a function.
3 min read
JavaScript Program to find Length of Linked List using JavaScript
Given a linked list, the task is to determine its length using various methods. The
linked list is a fundamental data structure consisting of nodes connected in a
chain, offering efficient data organization. Different approaches, including
Iterative and Recursive Methods, enable us to compute the length of a linked list
easily. Use the below approa
3 min read
course-img
86k+ interested Geeks
MERN Full Stack Web Development
Explore
course-img
27k+ interested Geeks
Complete Backend Development Program- Mastering OOPS, Spring Boot, and
Microservices
Explore
course-img
72k+ interested Geeks
JavaScript Full Course Online | Learn JavaScript with Certification
Explore
course-img
52k+ interested Geeks
Data Structures & Algorithms in JavaScript - Self Paced Course
Explore
course-img
167 interested Geeks
Front-End Interview Preparation Course
Explore
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh
(201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar,
Uttar Pradesh, 201305
GFG App on Play Store
GFG App on App Store
Advertise with us
Company
About Us
Legal
Privacy Policy
Careers
In Media
Contact Us
GFG Corporate Solution
Placement Training Program
Explore
Job-A-Thon Hiring Challenge
Hack-A-Thon
GfG Weekly Contest
Offline Classes (Delhi/NCR)
DSA in JAVA/C++
Master System Design
Master CP
GeeksforGeeks Videos
Geeks Community
Languages
Python
Java
C++
PHP
GoLang
SQL
R Language
Android Tutorial
DSA
Data Structures
Algorithms
DSA for Beginners
Basic DSA Problems
DSA Roadmap
DSA Interview Questions
Competitive Programming
Data Science & ML
Data Science With Python
Data Science For Beginner
Machine Learning
ML Maths
Data Visualisation
Pandas
NumPy
NLP
Deep Learning
Web Technologies
HTML
CSS
JavaScript
TypeScript
ReactJS
NextJS
NodeJs
Bootstrap
Tailwind CSS
Python Tutorial
Python Programming Examples
Django Tutorial
Python Projects
Python Tkinter
Web Scraping
OpenCV Tutorial
Python Interview Question
Computer Science
GATE CS Notes
Operating Systems
Computer Network
Database Management System
Software Engineering
Digital Logic Design
Engineering Maths
DevOps
Git
AWS
Docker
Kubernetes
Azure
GCP
DevOps Roadmap
System Design
High Level Design
Low Level Design
UML Diagrams
Interview Guide
Design Patterns
OOAD
System Design Bootcamp
Interview Questions
School Subjects
Mathematics
Physics
Chemistry
Biology
Social Science
English Grammar
Commerce
Accountancy
Business Studies
Economics
Management
HR Management
Finance
Income Tax
Databases
SQL
MYSQL
PostgreSQL
PL/SQL
MongoDB
Preparation Corner
Company-Wise Recruitment Process
Resume Templates
Aptitude Preparation
Puzzles
Company-Wise Preparation
Companies
Colleges
Competitive Exams
JEE Advanced
UGC NET
UPSC
SSC CGL
SBI PO
SBI Clerk
IBPS PO
IBPS Clerk
More Tutorials
Software Development
Software Testing
Product Management
Project Management
Linux
Excel
All Cheat Sheets
Recent Articles
Free Online Tools
Typing Test
Image Editor
Code Formatters
Code Converters
Currency Converter
Random Number Generator
Random Password Generator
Write & Earn
Write an Article
Improve an Article
Pick Topics to Write
Share your Experiences
Internships
DSA/Placements
DSA - Self Paced Course
DSA in JavaScript - Self Paced Course
DSA in Python - Self Paced
C Programming Course Online - Learn C with Data Structures
Complete Interview Preparation
Master Competitive Programming
Core CS Subject for Interview Preparation
Mastering System Design: LLD to HLD
Tech Interview 101 - From DSA to System Design [LIVE]
DSA to Development [HYBRID]
Placement Preparation Crash Course [LIVE]
Development/Testing
JavaScript Full Course
React JS Course
React Native Course
Django Web Development Course
Complete Bootstrap Course
Full Stack Development - [LIVE]
JAVA Backend Development - [LIVE]
Complete Software Testing Course [LIVE]
Android Mastery with Kotlin [LIVE]
Machine Learning/Data Science
Complete Machine Learning & Data Science Program - [LIVE]
Data Analytics Training using Excel, SQL, Python & PowerBI - [LIVE]
Data Science Training Program - [LIVE]
Mastering Generative AI and ChatGPT
Data Science Course with IBM Certification
Programming Languages
C Programming with Data Structures
C++ Programming Course
Java Programming Course
Python Full Course
Clouds/Devops
DevOps Engineering
AWS Solutions Architect Certification
Salesforce Certified Administrator Course
GATE
GATE CS & IT Test Series - 2025
GATE DA Test Series 2025
GATE CS & IT Course - 2025
GATE DA Course 2025
GATE Rank Predictor
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By
using our site, you acknowledge that you have read and understood our Cookie Policy
& Privacy Policy
Got It !
Lightbox

You might also like