Unit 3
Java Script: Java
Script: Introduction - Client side Java script - Server side Java script - Core
features – Data types and variables – Operators - Expressions and statements –
Functions – Objects – Array - Date and math related objects - Document objectmodel – Event handling
Logical Operators Types of Functions
Java Script
Introduction
v JavaScript is the programming language of the web.
v It can calculate, manipulate and validate data.
v It can update and change both HTML and CSS.
v JavaScript is
a versatile, dynamically typed programming language that brings life to web
pages by making them interactive.
v It is used
for building interactive web applications, supports both client-side and
server-side development, and integrates seamlessly with HTML, CSS, and a rich
standard library.
v Object oriented
v Platform
independent
v Update HTML
Using the DOM
v Capable of
Exception handling (Exception handling is a programming technique used to
manage errors or unexpected situations that occur during the execution of a
program.)
v Allows
Anonymous Functions
v (An anonymous
function in JavaScript is a function without a name. Unlike named
functions, these are typically used for specific tasks and are often assigned
to variables, passed as arguments, or executed immediately. They are
particularly useful in scenarios where the function does not need to be reused
outside its immediate context)
v JavaScript is
a single-threaded language that executes one task at a time.(Single threaded processes
contain the execution of instructions in a single sequence. In other
words, one command is processes at a time)
v It is an interpreted language which means it
executes the code line by line.
v The data type of the variable is decided at
run-time in JavaScript, which is why it is called dynamically typed.
Why Study JavaScript?
v JavaScript is an essential programming language for
modern development due to its versatility,
v Ease of use
v Widespread adoption
v It powers the majority of websites and applications,
making it a critical skill for developers.
v JavaScript enables dynamic and interactive web
experiences.
v Unlike static HTML and CSS, JavaScript allows
developers to create features like animations, form validations, and real-time updates without reloading the
page. (Real-time
updates are information that is delivered with minimal delay, as soon as
it becomes available. This is crucial for applications where immediate,
up-to-date information is necessary for decision-making, such as live sports
scores, stock prices, breaking news, and traffic conditions.)
v This makes websites more engaging and user-friendly.
v It is easy to learn and beginner-friendly, with a
simple syntax that resembles natural language. JavaScript runs directly in web
browsers, eliminating the need for complex setups. This accessibility makes it
an excellent starting point for new programmers.
v JavaScript is highly versatile. It can be used
for front-end development with frameworks (JavaScript
frameworks are collections of pre-written JavaScript code that provide a
structured foundation for building and managing complex web applications.) like React and Angular, back-end development
with Node.js, mobile app development using React Native, and even desktop
applications with Electron.
v It also supports advanced fields like machine learning
(TensorFlow.js) and blockchain development.
v The language has extensive community support,
offering a wealth of resources, tutorials, and libraries.
v Platforms like Stack Overflow and GitHub provide quick
solutions and collaboration opportunities, making it easier to overcome
challenges.
v JavaScript offers strong career prospects.
v It is one of the most in-demand programming languages,
with opportunities in web development, mobile development, and beyond.
v Companies like Google, Amazon, and Netflix actively
seek JavaScript developers, offering competitive salaries.
v In summary, JavaScript is indispensable for creating
modern, interactive applications across various platforms.
v Its versatility, ease of learning, and career
potential make it a must-have skill for developers.
Advantages of JavaScript
1.
Saves time
and bandwidth: Regardless of where you host
JavaScript, it always gets executed on the client environment to save lots of
bandwidth and make the execution process fast.
2.
Easily send
HTTP requests: In JavaScript,
XMLHttpRequest is an important object that was designed by Microsoft. The
object calls made by XMLHttpRequest as an asynchronous HTTP request to the
server to transfer the data to both sides without reloading the page
3.
Compatible
for all browsers: The
biggest advantage of JavaScript having the ability to support all modern
browsers and produce an equivalent result.
4.
Community
Support: Global companies support
community development by creating important projects. An example is Google
(created the Angular framework) or Facebook (created the React.js framework).
5.
Vastly used: JavaScript is employed everywhere on the web.
6.
Environment
Support: JavaScript plays nicely with
other languages and may be utilized in an enormous sort of application.
7.
Open source: Many open-source projects provide useful help for
developers to add JavaScript. (Open source is software with source code that is
publicly available for anyone to use, modify, and share freely.)
8.
Programming
language: There are many available
courses within the field of JavaScript, because of which you'll quickly and
simply expand your knowledge of this programming language.
9.
Easy to use: It is not difficult to start working in
JavaScript. For this reason, many of us prefer to start our adventure in the IT
sector by learning this language. It gives the power to make rich interfaces.
10. Backend usage: There are some ways to use JavaScript through Node.js servers. It is
possible to develop a whole JavaScript app from front to back using only
JavaScript.
Disadvantages of JavaScript
1.
This may be
difficult to develop large applications, although you'll also use the
TypeScript overlay.
2.
This applies
to larger front-end projects. The configuration is often a tedious task due to
the number of tools that are required to figure together to make an environment
for such a project. This is often directly associated with the library's
operation.
3.
The main
problem or disadvantage in JavaScript is that the code is always visible to
everyone anyone can view JavaScript code.
4.
No matter
what proportion fast JavaScript interprets, JavaScript DOM (Document Object
Model) is slow and can be a never-fast rendering with HTML.
5.
If the error
occurs in JavaScript, it can stop rendering the whole website. Browsers
are extremely tolerant of JavaScript errors. (In JavaScript, rendering refers to the process of dynamically updating the content of a web page.)
6.
JavaScript is
usually interpreted differently by different browsers. This makes it somewhat
complex to read and write cross-browser code
7.
Though some
HTML editors support debugging, it's not as efficient as other editors like
C/C++ editors. Hence difficult for the developer to detect the matter.
8.
This
continuous conversion takes longer than the conversion of a number to an
integer. This increases the time needed to run the script and reduces its
speed.
Client-side Java
script
What is
Client-Side Script, and how does it work?
1.
A client-side script is a tiny program (or collection of
instructions) that is put into a web page. It is handled by the client browser
rather than the web server.
2.
The client-side script, along with the HTML web page it is
embedded in, is downloaded from the server at the client end. The code is
interpreted and executed by the web browser, which then displays the results on
the screen.
3.
The client refers to the script that runs on the user’s
computer system. It can either be integrated (or injected) into the HTML
content or stored in a separate file (known as an external script).
4.
When the script files are requested, they are transmitted
from the web server (or servers) to the client system. The script is run by the
client’s web browser, which subsequently displays the web page, including any
visible script output.
5.
To further understand, look at the diagram below.
6.
Client-side scripts may also include instructions for the
web browser to follow in response to user activities like clicking a page
button. If a client wants to see the source code of a web page, they can
typically look at them.
7.
Client-side Scripting Languages are widely used.
8.
Client-side scripting language or client-side programming
refers to a language in which a client-side script or program is written
utilizing syntax.
Client-side Java
script
1.
Client-side scripting is when the server sends the code
along with the HTML web page to the client. The script is referred to by the
code.
2.
In other words, client-side scripting is a method for
browsers to run scripts without having to connect to a server.
3.
The code runs on the client’s computer’s browser either
while the web page is loading or after it has finished loading.
4.
Client-side scripting is mostly used for dynamic user
interface components including pull-down menus, navigation tools, animation
buttons, and data validation.
5.
It is currently quickly expanding and evolving on a daily
basis. As a result, creating client-side web programming has become easier and
faster, lowering server demand.
6.
By far the most popular client-side scripting languages or
web scripting languages, JavaScript and jQuery are frequently utilized to
construct dynamic and responsive webpages and websites.
7.
The browser downloads the code to the local machine
(temporarily) and begins processing it without the server. As a result,
client-side scripting is browser-specific.
The following
are the most popular client-side scripting languages:
1. JavaScript is the
most commonly used client-side scripting or programming language. It is written
in the ECMAScript programming language.
JavaScript is a dynamically typed (also known as weakly typed)
object-oriented scripting language. It uses an integrated interpreter to run
directly in the browser.
Weakly typed indicates that the variables can be implicitly
transformed from one data type to another.
2. VBScript: This
scripting language was developed by Microsoft, based on Visual Basic. It was
mostly used to improve the functionality of web pages in Internet Explorer. The
Internet Explorer web browser interprets VBScript. No one really uses it now.
3. jQuery: jQuery is a
JavaScript library that is fast, tiny, and lightweight. It’s used to turn a lot
of JavaScript code into user-friendly functionality.
The jQuery language is used by the majority of the world’s largest firms, including Google, Microsoft,
IBM, Netflix, and others.
Scripting on
the client-side
Client-side scripting is a technique
for enhancing the interactivity of online pages or websites. It’s mostly
utilized on the front end, where the
user can see what’s going on through their browser.
The following are some of the most common uses
of client-side scripting:
1.
To get data from a user’s screen or a web browser.
2.
In the realm of online games, this term is used.
3.
To make changes to a web page without having to reload it.
4.
Validation is done using client-side scripting. If a user
enters invalid credentials on the login page, the web page displays an error
notice on the client machine instead of sending the information to the web
server.
5.
Instead of simply displaying visuals, design ad banners
that interact with the user.
6.
To make animated pictures that change as the mouse moves
over them.
7.
A client-side script can be used to identify installed
plug-ins and alert the user if one is needed.
The Benefits
of Client-Side Scripting
The following
are some of the many benefits of client-side scripting:
1.
Client-side scripting is a simple language to learn and
utilize. It only necessitates rudimentary programming knowledge or experience.
2.
Client-side scripting has the advantage of being
lightweight and reasonably simple to implement (syntax not too complex). The
code modification and execution are both quick.
3.
Data processing is done on the client side instead of the
server, making large-scale applications easier to scale. As a result, the
server’s burden is reduced.
4.
Data validation on the client side can be accomplished
using a client-side scripting language such as JavaScript.
5.
Client-side script execution is faster since the script is
downloaded from the server and executed directly on the user’s machine via the
browser.
6.
Client-side scripting can also be used for mathematical
assessment.
7.
Client-side programming facilitates the completion of
complex activities in a limited number of steps.
8.
Script code that is only performed by the browser and not
by the server.
9.
Executing script code takes far too little time.
10. When a user
taps a key, moves the mouse, or clicks, the browser responds promptly.
Client-side
Scripting’s Drawbacks
The following
are some of the disadvantages of client-side scripting:
1.
Client-side scripting is insecure since the code is
transmitted to the client as is, and therefore visible to it if the client
looks at the source code of his web page. In a nutshell, code is almost always
visible.
2.
If we need to access databases or send sensitive data over
the internet, client-side programming is not an option.
3.
There is no guarantee that the user’s browser has JavaScript
enabled. As a result, notwithstanding the possibility of offloading, all
essential functions must be loaded on the server.
4.
The script’s (or program’s) smooth operation is entirely
dependent on the client’s browser, its settings, and its security level.
5.
Debugging and maintaining a web application relying on
excessive JavaScript might be difficult.
6.
Client-side scripting languages are typically more
constrained than server-side scripting languages in terms of capabilities.
No comments:
Post a Comment