Skip to main content

Command Palette

Search for a command to run...

JavaScript Introduction

Chapter 4 with examples

Updated
2 min readView as Markdown
JavaScript Introduction
A

I am a passionate front-end engineer with 3 years of experience in developing and implementing innovative software solutions.

Hello everyone, My name is Arinze Calistus. The purpose of this blog is to teach you all you need to know about JavaScript/Programming.

JavaScript Statements

JS programs consist of statements with appropriate syntax. A single JS statement may span a single or multiple lines. JS statements should also be ended or separated by semicolons ;.

Below is an example of a single-line statement. This statement writes the text "Hello World!" to the paragraph element with the demo id.

document.getElementById("demo").innerHTML="Hello World!"

Below is a program that consists of two single-line statements. You can have as many statements as you need when writing programs.

document.getElementById("demo 1").innerHTML="Hello World!"
document.getElementById("demo 2").innerHTML="Hello Everyone!"

Grouping JavaScript Statements

JS statements can be grouped inside curly brackets {...}. These are called code blocks. Code blocks are used to make statements execute together. They are commonly used in functions.

function myfunc() {
document.getElementById("demo 1").innerHTML="Hello World!"
}

JavaScript Keywords

JS statements usually start with a keyword. Each keyword in JS has its own special meaning. For example, to declare a variable, we have to use the var keyword.

function myfunc() {
var text = "Hello World!";
document.getElementById("demo 1").innerHTML="Hello World!"
}

We will go through JavaScript keywords as you continue reading my articles. Thanks for reading this blog. Let me know what you think about it. PEACE!

JavaScript

Part 4 of 11

This blog is all about JavaScript topics from Basics to Advance, along with interview question.

Up next

JavaScript 5

Chapter 5 with Examples

More from this blog

A

Arizon.Dev

12 posts

Hi everyone, My name is Arinze Calistus and I'm a self-taught Full-Stack developer that learned and is still learning through online resources. I would love to connect with people and have a chat.