Professional Documents
Culture Documents
JAVASCRIPT IN Automation Anywhere A360
JAVASCRIPT IN Automation Anywhere A360
A360
Introduction
JavaScript is a programming language that allows you to implement complex things on web pages.
It is dynamically typed programming language.
JavaScript gives HTML designers a programming tool.
JS is both a client side and server-side scripting language.
Where Can We Run JS:
Adding JS to your HTML files.
In browser console
In your local machine by installing Node.JS
JavaScript Variables
4 Ways to Declare a JavaScript Variable:
• Using var
• Using let
• Using const
• Using nothing
If you want a general rule: always declare variables with const.
If you think the value of the variable can change, use let.
5 + 5 = 10
"5" + 5 = "55"
With the object model, JavaScript gets all the power it needs to create dynamic HTML:
JavaScript can change all the HTML elements in the page
JavaScript can change all the HTML attributes in the page
JavaScript can change all the CSS styles in the page
JavaScript can remove existing HTML elements and attributes
JavaScript can add new HTML elements and attributes
JavaScript can react to all existing HTML events in the page
JavaScript can create new HTML events in the page
JavaScript DOM
Methods Description
document.getElementById() Select the unique element with given id. In case there are 2 same ID
then it selects the first element.
document.getElementsByClassName() Select collection elements with given classname
document.getElementsByTagName() Select collection elements with given tagname
document.querySelector() Select element the first element on the basic of CSS string
document.querySelectorALL() Select a list of elements on the basic of CSS string
JavaScript Events
The change in the state of an object is known as an Event. When javascript code is included in HTML, js reacts
over these events and allow the execution. This process of reacting over the events is called Event Handling.
mouseover onmouseover When the cursor of the mouse comes over the element
mouseup onmouseup When the mouse button is released over the element
change onchange When the user modifies or changes the value of a form element
Keydown Onkeydown When the user press and then release the key
JavaScript Fetch
The fetch() method in JavaScript is used to request to the server and load the information on the webpages. The
request can be of any APIs that return the data of the format JSON or XML. This method returns a promise.
fetch("api/SampleData",
{
body: formData,
method: "post"
});