0% found this document useful (0 votes)
4 views5 pages

Java Script Lecture 01

JavaScript is a client-side, object-based scripting language developed by Netscape and Sun Microsystems, known for its dynamic web page capabilities and standardized as ECMAScript. It is lightweight, platform-independent, and executed in browsers using various engines, allowing for both client-side and server-side applications. Key features include being interpreted, asynchronous, and having its own syntax for variables and functions, with multiple methods for outputting results on web pages.

Uploaded by

hafsahakim406
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Java Script Lecture 01

JavaScript is a client-side, object-based scripting language developed by Netscape and Sun Microsystems, known for its dynamic web page capabilities and standardized as ECMAScript. It is lightweight, platform-independent, and executed in browsers using various engines, allowing for both client-side and server-side applications. Key features include being interpreted, asynchronous, and having its own syntax for variables and functions, with multiple methods for outputting results on web pages.

Uploaded by

hafsahakim406
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript is a client-side, object-based scripting language that is used to handle and validate client-side

data. JavaScript is also used for making the user interface of the web pages more dynamic making it
responsive to events like the movement of the mouse, mouse click on a certain HTML element, a button
click, etc,

JavaScript, formerly known as LiveScript, has been developed by Netscape and Sun Microsystems. It is also
known as ECMAScript as it was standardized by European Computer Manufacturer's Association(ECMA).

JavaScript is a lightweight scripting language based on ECMAScript standards. It executes on the


browser and therefore reduces the load on the server. JavaScript can also be used to create cross-platform
applications or SaaS applications or to create a Back-end server-side application by using NodeJS.

It is an interpreted language which means the script written inside Javascript is processed line by line and
is not compiled before processing. These Scripts are interpreted by JavaScript interpreter which is a built-
in component of the Web browser.

JavaScript is Platform Independent, which means you need to write the script once and can run it on any
platform or browser without affecting the output of the Script.

Browsers use their own JavaScript Engines to execute the JavaScript code. Some commonly used
browsers are listed below:

• Chrome uses a V8 engine.


• Firefox uses the SpiderMonkey engine.
• Microsoft Edge uses the ChakraCore engine.
• Safari uses the SquirrelFish engine.

JavaScript Features

Following are some of the most useful features of JavaScript:

• Light Weight
• Dynamically Typed
• Object-Based
• Functional
• Platform Independent
• Prototype-based
• Interpreted
• Asynchronous

JavaScript Syntax
JavaScript has its own syntax and programming style. Syntax of a language defines rules of
writing the code in that language, what is the correct way and what is not. In this tutorial, we will
learn about the basic syntax for writing code in JavaScript.

JavaScript uses its own syntax to create variable, function, statements, etc. but if you have
knowledge of any programming language like C, C++ or Java, it won't be very difficult for you to
understand the syntax of JavaScript.

• A semicolon at the end of every statement (is Optional)


• JavaScript White Spaces and Line Breaks
• JavaScript Case Sensitivity
• JavaScript Comments

Single line Comments //


Multiline Comments /* */

• JavaScript Statements : <script > tag is used to write java script code.

Output in JavaScript
we can get JavaScript Output in 4 simple and different ways on a webpage and these are given
below. We can use them according to the application requirement. In this tutorial, we will be
learning the following four different ways of getting output from JavaScript code, just like we
use printf() in C language, cout in C++, etc.

1. Using innerHTML property


2. Using [Link]() method
3. Using Alert Box
4. By logging on the Console

1. JavaScript innerHTML Property

JavaScript lets you write into an HTML element by using innerHTML property. We can add
anything we want, it can be a text message, some HTML element or anything else.

To do that first you need to provide a specific Id to the HTML element that you want to access
by the JavaScript code.

To access an HTML element JavaScript uses [Link](id) method, where id is the value
of the id attribute of the HTML tag.

Let's take an example, in this example, id attribute is used to identify the HTML element
and innerHTML property is used to set content to it.
2. JavaScript Output using [Link]()

JavaScript lets you write any outout into the HTML webpage by using the [Link]() method.
By using this method you can directly write output to the HTML page.

The write() method writes the HTML expressions or JavaScript code to a document. This method is
mostly used for testing purposes.

Let's take an example, in this example, we are using [Link]() method which is used to write
to the webpage directly.

3. JavaScript Output via Alert Box

There are certain websites that give you alert messages when you access them or when you
perform some action you see the output message in alert boxes. You can also make your webpage
to send alert messages to notify something to the user using JavaScript, to use this feature you
need to use the [Link]() method.

Let's take an example, in this example, we are using the alert box to write a message and show to
the user.
4. JavaScript Console Logging

JavaScript also lets you create console logs which can be seen in the browser's developers'
tools(Console) for debugging purposes. The statement written inside a console log will be
executed but would not be displayed in the browser instead it will be displayed inside the console
of the browser.

The function used for console logging is [Link](SOME-EXPRESSION-OR-STRING) which can be


used to log anything in the browser's console.

To open developer's tools in the Chrome browser, press F12 in Windows and Command +
Option + I in MacOS. The picture below shows how it looks:

JavaScript Variables
JavaScript Variable is an object(or a named memory space) that is used to store a value that can
be used during program execution. A variable in JavaScript, just like in other programming
languages, has a name, a value, and a memory address.

• The name of the variable uniquely identifies the variable,


• The value refers to data stored in the variable, and
• The memory address refers to the memory location of the variable.

In other words, we can say that variable is a container that can be used to store value and you
need to declare a variable before using it.

In JavaScript, the var and let keyword is used to declare a variable.

You might also like