JavaScript is a browser-based scripting language. With JavaScript, you add behavior to the HTML documents and control the browser or change the HTML document.
The best way to learn JavaScript is to try many examples. JavaScript is also a complex programming language, it is not easy to learn JavaScript just because it is a browser language. You must practice lots of examples.
The examples are divided broadly into two categories – basic examples and object-oriented examples. The basic example demonstrates the fundamental concepts of JavaScript and object-oriented examples, you learn about object-oriented programming concepts.
Prerequisites
You need to complete certain prerequisites to get started with JS examples. These are tools and learning resources to help you learn JavaScript efficiently.
- JavaScript tutorial – you must be familiar with JavaScript concepts and the best way to learn is either visit our JavaScript tutorial page or get a good easy to follow JavaScript book with examples.
- Notepad – to write programs you need a text editor and browser can interpret the scripts easily. Download a new editor like Bracket, Sublime Text, Notepad++ or use builtin text editors – Notepad or Text Edit in Mac.
- Browser – you need to install a browser to test you JavaScript code. You can download free browsers from internet like Chrome, Mozilla Firefox, UC Browser, Microsoft Edge, etc.
JavaScript exercises
Sub topics for JavaScript listed below.
JavaScript Basic Examples
- Ex 01: First Script
- Ex 02: Output to HTML
- Ex 03: Alert Boxes
- Ex 04: External JavaScript Files
- Ex 05: Variable Declarations
- Ex 06: Conditional Statements
- Ex 07: Switch-Case Statements
- Ex 08: Alert, Confirm, & Prompt
- Ex 09: For Loop
- Ex 10: The While Loop
- Ex 11: The Do-While Loop
- Ex 12: Arrays
JavaScript Object Exercises
JavaScript Algorithm Examples
- Celsius To Fahrenheit
- Find Factorial Of A Number
- Reverse A String
- Find Longest Word In A String
- Find The Largest Number
- Repeat A String
- Truthy & Falsy
JavaScript Projects
JavaScript References
- repeat()
- endsWith()
- split()
- substring()
- toUpperCase()
- toLowerCase()
- indexOf()
- lastIndexOf()
- join()
- push()
- pop()
- unshift()
- shift()
- slice()
- splice()