DEV Community

Sabitha
Sabitha

Posted on

Basics of Javascript

JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.

JavaScript on Client Side:
On the client side, JavaScript works along with HTML and CSS. HTML adds structure to a web page, CSS styles it, and JavaScript brings it to life by allowing users to interact with elements on the page, such as actions on clicking buttons, filling out forms, and showing animations. JavaScript on the client side is directly executed in the user's browser.

JavaScript on server side:

JavaScript on Server Side: On the Server side (on Web Servers), JavaScript is used to access databases, file handling, and security features to send responses, to browsers.

Types of datatypes

primitive datatypes

Data Type Example Description
String "Hello" Text inside quotes
Number 42, 3.14 Integer or decimal
Boolean true, false Yes/No, On/Off
Undefined let x; Declared but not assigned
Null let x = null; Empty or unknown value
BigInt 12345678901234567890n Very large numbers
Symbol Symbol("id") Unique and immutable value

Non-primitive

Data Type Example Description
Object {name: "Sabitha", age: 22} Collection of key-value pairs
Array [1, 2, 3] Ordered list of values
Function function() {} Block of reusable code

Arithmetic Operators:

  • Operator Description
  • + Addition
  • - Subtraction
  • * Multiplication
  • ** Exponentiation (ES2016)
  • / Division
  • % Modulus (Division Remainder)
  • ++ Increment
  • -- Decrement

What is an object?

An object in JavaScript is a data structure that allows you to store multiple values in a single variable using key–value pairs.

ATTRIBUTES:

In JavaScript, we can access, change, or remove the attributes of HTML elements using the DOM (Document Object Model).

Attributes are things like: href, src, id, class, value, etc.

Top comments (0)