DONATE  
MENU
JSON
MYSQL
CSS
AJAX
HTML
JAVASCRIPT
PHP

JavaScript Tutorials

INTRODUCTION

» Introduction to JavaScript

» Practice IT Editor

» JavaScript Example

» JavaScript Placement

» JavaScript Syntax

» JavaScript Statements

» JavaScript Input

» JavaScript Output

» JavaScript Comments

» JavaScript Variables

» Variables' Scope

» JavaScript Operators

» JS Expressions & Concatenation

» JavaScript Data Type

» JavaScript Numbers

» Number Object

» JavaScript Strings

» String Object

» JavaScript Booleans

» Boolean Object

» JavaScript Functions

» JavaScript Arrays

» Array Object - Properties

» Array Object - Methods

» JavaScript Objects

» JavaScript Undefined

» JavaScript Nulls

CONDITIONAL TESTING

» If Statement

» If Else Statement

» JavaScript Ternary Operator

» Switch Statement

LOOPS

» For Loops

» While Loops

» Break & Continue

» For...In Loops

» do...while Loop

FUNCTIONS

» JavaScript Functions

» Creating Functions

» Functions' Parameters

» Functions' Arguments

» Function Invocation

» The Return Keyword

» The Arguments Object

» Callback Functions

» Arrow Functions

ARRAYS

» JavaScript Arrays

» Creating Arrays

» Accessing Arrays

» Looping Arrays

» Multi - dimensional Arrays

OBJECTS

» JavaScript Objects

» Creating Objects

» Prototype Definition

» Accessing Objects

» The this Keyword

AJAX

» Introduction to AJAX

JSON

» Introduction to JSON

JAVASCRIPT DATES

» The Date Object

» Date Methods

» Timing (SetInterval & SetTimeout)

MATH OBJECT

» Math Object

» Math Methods

HTML / JS DOM

» DOM Introduction

» Accessing HTML Elements in DOM

» Get And Change Elements' Contents & Values

» Change Styling - DOM CSS

» DOM Attributes

» JavaScript Event Listeners

» DOM Event Listeners

» JS Events

MISCELLANEOUS

» JS Strict Mode

» JavaScript Hoisting

» JavaScript let keyword

» Reserved Keywords

» JS Best Practices

» JavaScript vs ECMAScript

JAVASCRIPT EXAMPLES

» JavaScript Calculator

.. » JavaScript » Introduction » JavaScript Example
Share Tweet WhatsApp

JavaScript Example

Below are examples of JavaScript being used in webpages. This is to give you a basic insight into the practical use of JavaScript in creating websites.
KeyNote: As a beginner, you may not understand the examples but then, as you proceed further into the tutorial, you will get familiarized with them.
Using JavaScript to display a text when a website loads.
<script>
//DEFINING A FUNCTION
function myFunction(){
alert("Hello World");
}

//CALLING THE FUNCTION TO WORK
myFunction();
</script>

Copy PRACTICE IT

Using JavaScript to change the content of a webpage after loading and when a web user clicks a button.
<!-- HTML -->
<div><h1 id='h'>Hello World</h1></div>
<p><button onclick='ask()'>ASK ME</button></p>

<!-- JAVASCRIPT -->
<script>
function ask(){
document.getElementById("h").innerHTML = "How are you today?";
}
</script>

Copy PRACTICE IT

Take a short quiz on JavaScript Example.
Ask a question or tell us if JavaScript Example is easy or not.
cent?

Join our 1,090 subscribers to receive tutorials' updates!

  We won't spam your mail box. We hate it.





StackBeginner 2021 © Joseph Omamode