JavaScript Examples I
Where to Insert JavaScript
JavaScript in <head>
JavaScript in <body>
An external JavaScript
JavaScript Statements, Comments and Blocks
JavaScript statements
JavaScript blocks
Single line comments
Single line comments at the end of a line
Multiple lines comments
Single line comment to prevent execution
Multiple lines comment to prevent execution
JavaScript Variables
Declare a variable, assign a value to it, and display it
Create numeric variables
Create variables of different types
Add two numbers
Add two strings
JavaScript Data Types
Declare (create) numbers
Declare (create) strings
Declare (create) an array
Declare (create) an object
Use typeof to find the type of variables
Undefined and null
JavaScript Functions
Call a simple function
Call a function with an argument
Call a function with an argument 2
Call a function that returns a value
Call a function that converts
Fahrenheit to Celsius
JavaScript Events
An onclick event changes an HTML element
An onclick event changes its own element
An onclick event calls a function
JavaScript Strings
Show some string examples
Find the length of a string
Find the position of the first occurrence of a text in a string - indexOf()
Search for a text in a string and return the text if found - match()
Replace characters in a string - replace()
Convert string to upper case - toUpperCase()
Convert string to lower case - toLowerCase()
Split a string into an array - split()
Your suggestion:
Thank You For Helping Us!
Your message has been sent to W3Schools.