JavaScript
CheatSheet
,In this Cheatsheet, we will cover the basics of JavaScript. We will
provide examples to help you understand how JavaScript work
and how to use them in your own web development projects.
Whether you are a beginner or an experienced developer, this PDF
can serve as a useful reference guide.
JavaScript
JavaScript is a programming language that is widely used in web
development. It is a client-side scripting language, which means
that it is executed on the client side (in a web browser) rather than
on the server side. JavaScript is used to create interactive web
pages and is an essential component of modern web development.
It is a high-level, dynamically typed language that is interpreted,
which means that it is not compiled into machine code before it is
run. JavaScript is used to add functionality to websites, such as
handling user events (such as clicks and form submissions),
animating page elements, and making asynchronous requests to
servers. It is a versatile language that can be used for a wide
range of applications, from simple scripts that add simple
interactivity to websites to complex single-page applications.
On page script:
<script type="text/javascript"> .... </script>
Include external JS file:
<script src="filename.js"></script>
2|Page
, Delay - 1 second timeout:
setTimeout(function () {
}, 1000);
Functions:
function addNumbers(a, b) {
return a + b; ;
}
x = addNumbers(1, 2);
Edit DOM element:
document.getElementById("elementID").innerHTML = "Hello World!";
Output:
console.log(a); // write to the browser console.
document.write(a); // write to the HTML.
alert(a); // output in an alert box.
confirm("?"); // yes/no dialog, returns true/false depending on user click.
prompt("Age ?","0"); // input dialog box. (Initial Value = 0).
3|Page
CheatSheet
,In this Cheatsheet, we will cover the basics of JavaScript. We will
provide examples to help you understand how JavaScript work
and how to use them in your own web development projects.
Whether you are a beginner or an experienced developer, this PDF
can serve as a useful reference guide.
JavaScript
JavaScript is a programming language that is widely used in web
development. It is a client-side scripting language, which means
that it is executed on the client side (in a web browser) rather than
on the server side. JavaScript is used to create interactive web
pages and is an essential component of modern web development.
It is a high-level, dynamically typed language that is interpreted,
which means that it is not compiled into machine code before it is
run. JavaScript is used to add functionality to websites, such as
handling user events (such as clicks and form submissions),
animating page elements, and making asynchronous requests to
servers. It is a versatile language that can be used for a wide
range of applications, from simple scripts that add simple
interactivity to websites to complex single-page applications.
On page script:
<script type="text/javascript"> .... </script>
Include external JS file:
<script src="filename.js"></script>
2|Page
, Delay - 1 second timeout:
setTimeout(function () {
}, 1000);
Functions:
function addNumbers(a, b) {
return a + b; ;
}
x = addNumbers(1, 2);
Edit DOM element:
document.getElementById("elementID").innerHTML = "Hello World!";
Output:
console.log(a); // write to the browser console.
document.write(a); // write to the HTML.
alert(a); // output in an alert box.
confirm("?"); // yes/no dialog, returns true/false depending on user click.
prompt("Age ?","0"); // input dialog box. (Initial Value = 0).
3|Page