DEV Community

Karthick (k)
Karthick (k)

Posted on

Introduction - JavaScript

Q1. Client-side scripting :

Web browsers execute client-side scripting. It is used when browsers have all the code. Source code is used to transfer from the web server to the user's computer over the internet and run directly in browsers. It is also used for validations and functionality for user events.

Q2. Server-side scripting :

Web servers are used to execute server-side scripting. They are basically used to create dynamic pages. It can also access the file system residing on the web server. A server-side environment that runs on a scripting language is a web server.

Q3.What is Localhost?

In computer networking, a host means a “server”. Just like you can put a website on the internet by hosting it on a server, you can make your own computer that serves as a server. This connection is called loopback. The IP address for that loopback is 127.0.0.1.

Q4.JavaScript Data Types

JavaScript data types define what kind of values a variable can hold and how those values behave in a program. They determine how data is stored in memory and how operations like comparison, calculation, and conversion work.

Q5.Here is a list of JavaScript Engines for major Internet browsers:

V8 — JavaScript Engine developed by Google for Chrome
SpiderMonkey — The JavaScript Engine used by Mozilla Firefox
JavaScriptCore — Developed by Apple for Safari
Rhino — Managed by Mozilla Foundation for Firefox
Chakra — A JavaScript Engine for Microsoft Edge
JerryScript — A JavaScript Engine employed for the Internet of Things (IoT).

Q8.JavaScript Operators

JavaScript operators are symbols or keywords used to perform operations on values and variables. They are the building blocks of JavaScript expressions and can manipulate data in various ways.

&-->JavaScript Arithmetic Operators

Arithmetic Operators perform mathematical operations such as addition, subtraction, and multiplication.

const sum = 5 + 3; // Addition
const diff = 10 - 2; // Subtraction
const p = 4 * 2; // Multiplication
const q = 8 / 2; // Division
console.log(sum, diff, p, q);

&--> JavaScript Assignment Operators

Assignment operators are used to assign values to variables. They can also perform operations like addition or multiplication while assigning the value.

let n = 10;
n += 5;
n *= 2;
console.log(n);

&--> JavaScript Comparison Operators

Comparison operators compare two values and return a Boolean (true or false). They are useful for making decisions in conditional statements.

console.log(10 > 5);
console.log(10 === "10");

&--> JavaScript Logical Operators

Logical operators are mainly used to perform logical operations that determine equality or difference between values.

const a = true, b = false;
console.log(a && b); // Logical AND
console.log(a || b); // Logical OR

&--> JavaScript Bitwise Operators

Bitwise operators perform operations on binary representations of numbers.

const res = 5 & 1; // Bitwise AND
console.log(res);

&--> JavaScript Ternary Operator

The ternary operator is a shorthand for conditional statements. It takes three operands.

const age = 18;
const status = age >= 18 ? "Adult": "Minor";
console.log(status);

&--> JavaScript Comma Operator

Comma Operator (,) mainly evaluates its operands from left to right sequentially and returns the value of the rightmost operand.

let n1, n2
const res = (n1 = 1, n2 = 2, n1 + n2);
console.log(res);

&--> JavaScript Unary Operators

Unary operators operate on a single operand (e.g., increment, decrement).

`let x = 5;

console.log(+x);
console.log(-x);

console.log(++x);
console.log(--x);

console.log(!x);`

&--> JavaScript Relational Operators

JavaScript Relational operators are used to compare their operands and determine the relationship between them. They return a Boolean value (true or false) based on the comparison result.

const obj = { length: 10 };
console.log("length" in obj);
console.log([] instanceof Array);

&--> JavaScript BigInt Operators

BigInt operators allow calculations with numbers beyond the safe integer range.

const big1 = 123456789012345678901234567890n;
const big2 = 987654321098765432109876543210n;
console.log(big1 + big2);

&--> JavaScript String Operators

JavaScript String Operators include concatenation (+) and concatenation assignment (+=), used to join strings or combine strings with other data types.

const s = "Hello" + " " + "World";
console.log(s);

&--> JavaScript Chaining Operator (?.)

The optional chaining operator allows safe access to deeply nested properties without throwing errors if the property doesn’t exist.

const obj = { name: "Aman", address: { city: "Delhi" } };
console.log(obj.address?.city);
console.log(obj.contact?.phone);

Q8:typeof

The typeof operator returns a string indicating the type of the operand's value.

Q9:JavaScript Type Conversion

In JavaScript, Type Conversion can be defined as converting the data type of the variables from one type to another manually by the programmer(explicitly) or automatically by JavaScript(implicitly).

Implicit Type Conversion (Coercion): Implicit Type Conversion occurs automatically in JavaScript.

Explicit Type Conversion: Explicit Type Conversion occurs when the programmer manually changes the type of the variables using the functions Number(), String(), and Boolean().

Top comments (1)

Collapse
 
kamalesh_ar_6252544786997 profile image
Kamalesh AR

Nice one bro