Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

JavaScript (JS) is a text-based programming language used both on the client-side

and server-side that allows you to make web pages interactive. It is one of the three
core technologies of World Wide Web content production, alongside HTML and CSS.

Here are some of the basics of JavaScript:

● Data types: JavaScript has seven primitive data types: undefined, null,
Boolean, number, string, object, and symbol.
● Variables: Variables are used to store data. To declare a variable, you use the
var keyword. For example:

JavaScript
var name = "Alice";

Use code with caution. Learn more


content_copy
● Constants: Constants are used to store data that does not change. To declare
a constant, you use the const keyword. For example:

JavaScript
const PI = 3.14;

Use code with caution. Learn more


content_copy
● Operators: Operators are used to perform operations on data. JavaScript has
many different operators, including arithmetic operators, comparison
operators, and logical operators. For example:

JavaScript
// Arithmetic operator
var sum = 1 + 2;

// Comparison operator
var isGreaterThan = 1 > 2;

// Logical operator
var isTrue = 1 > 2 && 2 > 3;

Use code with caution. Learn more


content_copy
● Functions: Functions are used to group code together and to perform specific
tasks. To define a function, you use the function keyword. For example:
JavaScript
function greet(name) {
console.log(`Hello, ${name}!`);
}

greet("Alice");

Use code with caution. Learn more


content_copy
● Objects: Objects are used to store data in a structured way. To create an
object, you use the {} curly braces. For example:

JavaScript
var person = {
name: "Alice",
age: 25
};

console.log(person.name); // "Alice"

Use code with caution. Learn more


content_copy
● Arrays: Arrays are used to store data in a linear order. To create an array, you
use the [] square brackets. For example:

JavaScript
var numbers = [1, 2, 3, 4, 5];

console.log(numbers[2]); // 3

Use code with caution. Learn more


content_copy
● Control flow: JavaScript has control flow statements that allow you to control
the flow of execution of your code. These statements include if, else,
while, and for. For example:

JavaScript
if (name === "Alice") {
console.log("Hello, Alice!");
} else {
console.log("Hello!");
}
Use code with caution. Learn more
content_copy

This is just a basic overview of JavaScript. There is much more to learn, but this
should give you a good starting point.

Here are some resources to learn more about JavaScript:

● Mozilla Developer Network (MDN) JavaScript documentation:


https://developer.mozilla.org/en-US/docs/Web/JavaScript
● W3Schools JavaScript tutorial: https://www.w3schools.com/js/
● JavaScript.info: https://javascript.info/
● Eloquent JavaScript: https://eloquentjavascript.net/

I hope this helps!

You might also like