JavaScript is a programming language is an artificial language used to instruct computers. Programming allows you to accomplish tasks that would otherwise take forever.Javascript is a programming language that was introduced in 1995 as a way to add programs to the Netscape Navigation browser.Node is used for third-party libraries.
All JavaScript codes are terminated by a semicolon
console.log("Hello world");
Script tag
JavaScript uses the script tag at the bottom of the body tag because JavaScript runs code from top to bottom and if on top the other elements won't run.
!DOCTYPE html>
Document console.log("Hello world");
Comments.
Comments are used to communicate the intent of your code. These are lines of code that JavaScript intentionally ignores.
//this is my first in-line comment
let a = "Natete Verite"
console.log(a)
/This is a multi-line comment, looks like we will do it differently/
Data Types.
JavaScript has primitives and non-primitive data types.
JavaScript has different data types: undefined, null, boolean, string, symbol, bigint, number, and object.
Reference data types include data types that are dynamic in nature and they don't have a fixed size.
When naming variables, a variable name cannot be a keyword
Computers can perform mathematical operations on a number and not a string.
Undefined
Variables defined in JavaScript values are undefined by default unless initialized.
let student;
console.log(student);
String
A sequence of characters often declared by single
quotes, double quotes, or backticks
let student='Jael';
console.log(student);
let relate="Joy";
console.log(relate);
let date=Kirigo
;
console.log(date);
Boolean
Boolean values are either true or false.
let houseBought=true;
let education=false;
Null- Defined variable that is missing a value.
Variables
Variables in JavaScript are named using the camel notation.
Variables are case-sensitive.
let firstname='Conslate';
let lastname='Koyo';
Let can be manipulated. The expected output is 1.
let student=2;
student=1
console.log(student)
To avoid manipulation of the output, one is expected to use const to declare variables.
const student=2;
student=1
console.log(student)
Objects
Objects are seen as a collection of properties
When dealing with multiple related variables, one ca use an object.
let person={
name:"Shysh",
age:26,
country:"Kenya",
city: "Nairobi"
}
console.log(person)
In order to access the attributes of an object, we use the dot notation method.
person. name
console.log(person. name)
One can also use bracket notation to access elements in an object.
person['name']='Steve'
console.log(person. name)
Arrays
Arrays are objects in JavaScript.
The collection of different data types enclosed by square
Brackets.
letselectedCountries=["kenya","Uganda","Somalia","Rwanda","SouthSudan"];
console.log(selectedCountries[2])
Adding elements in an array.
let selectedCountries=["Kenya","Uganda","Somalia","Rwanda","SouthSudan"];
console.log(selectedCountries[2])
selectedCountries[5]="Zambia"
console.log(selectedCountries)
Top comments (2)
Good article, keep going
Nicely written sis 💪💪