Web Programming
Web Programming
<script>
// JavaScript Code
</script>
example
<!DOCTYPE html>
<html lang="en">
<head>
<title>
Basic Example to Describe JavaScript
</title>
</head>
<body>
</html>
History of JavaScript
• It was created in 1995 by Brendan Eich while he was an engineer at Netscape. It
was originally going to be named LiveScript but was renamed. Unlike most
programming languages, JavaScript language has no concept of input or output. It
is designed to run as a scripting language in a host environment, and it is up to the
host environment to provide mechanisms for communicating with the outside
world. The most common host environment is the browser.
• Features of JavaScript
• According to a recent survey conducted by Stack Overflow, JavaScript is the most
popular language on earth.
With advances in browser technology and JavaScript having moved into the server
with Node.js and other frameworks, JavaScript is capable of so much more. Here are
a few things that we can do with JavaScript:
• JavaScript was created in the first place for DOM manipulation. Earlier websites
were mostly static, after JS was created dynamic Web sites were made.
• Functions in JS are objects. They may have properties and methods just like other
objects. They can be passed as arguments in other functions.
• Can handle date and time.
• Performs Form Validation although the forms are created using HTML.
• No compiler is needed.
Applications of JavaScript
• Web Development: Adding interactivity and behavior to static sites JavaScript was
invented to do this in 1995. By using AngularJS that can be achieved so easily.
• Web Applications:With technology, browsers have improved to the extent that a
language was required to create robust web applications.
• Server ApplicationsWith the help of Node.js, JavaScript made its way from client to
server and Node.js is the most powerful on the server side.
• Games:Not only in websites, but JavaScript also helps in creating games for leisure.
The combination of JavaScript and HTML 5 makes JavaScript popular in game
development as well.
• SmartwatchesJavaScript is being used in all possible devices and applications. It
provides a library PebbleJS which is used in smartwatch applications.
• ArtArtists and designers can create whatever they want using JavaScript to draw on
HTML 5 canvas, and make the sound more effective also can be used p5.js library.
• Machine Learning: This JavaScript ml5.js library can be used in web development
by using machine learning.
• Mobile Applications: JavaScript can also be used to build an application for non-
web contexts.
Limitations of JavaScript
• JavaScript Identifiers
• JavaScript variables must have unique names. These
names are called Identifiers.
• There are some basic rules to declare a variable
in JavaScript:
• These are case-sensitive
• Can only begin with a letter, underscore(“_”) or “$”
symbol
• It can contain letters, numbers, underscore, or “$”
symbol
• A variable name cannot be a reserved keyword.
JavaScript var is a keyword used to declare variables in JavaScript
that are function scoped. Before the introduction of ES6 all the
keywords in JavaScript were declared with only “var” keyword. The
var keyword is also used to declare global-scope variables.
Syntax:
var variableName = valueOfVar;
Function Scope: The variables declared inside a function are
function scoped and cannot be accessed outside the function. The
variables declared with var can only be accessed inside that
function and its enclosing function.
example
• 1. var test = 12
• function foo(){
• console.log(test);
• }
• foo();
• Output=12