JavaScript Basics

This is a sample post about JavaScript basics.

Variables

JavaScript has three ways to declare variables:

1
2
3
var oldWay = 'var is function-scoped';
let blockScoped = 'let is block-scoped';
const constant = 'const cannot be reassigned';

Functions

Functions are first-class citizens in JavaScript:

1
2
3
4
5
function greet(name) {
return `Hello, ${name}!`;
}

const arrow = (name) => `Hello, ${name}!`;

Stay tuned for more JavaScript tutorials!