[go: up one dir, main page]

0% found this document useful (0 votes)
6K views3 pages

Javascript Was Developed by Netscape Communications Corporation, A Now-Defunct Technology Company. It Was Created by Brendan Eich in 1995

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

 Which company developed JavaScript?

JavaScript was developed by Netscape Communications Corporation, a now-defunct technology


company. It was created by Brendan Eich in 1995
 What are JavaScript Data Types?
Primitive Data Types:

Undefined: Represents an uninitialized or undefined value.


Null: Represents the intentional absence of any value.
Boolean: Represents a true or false value.
Number: Represents both integer and floating-point numeric values.
String: Represents a sequence of characters (text).
Symbol: Introduced in ECMAScript 6 (ES6), represents a unique and immutable value, often used as
object property keys.
BigInt: Also introduced in ES6, represents arbitrarily large integers.
Reference Data Types:

Object: Represents a collection of key-value pairs. Objects can include functions, arrays, and other
objects.
Array: Represents an ordered list of values, accessed by their numeric index.
Function: Represents a block of code that can be invoked or executed.
Date: Represents a specific point in time.
RegExp: Represents a regular expression, used for pattern matching in strings.
Map: Represents a collection of key-value pairs with keys that can be of any data type.
Set: Represents a collection of unique values.
WeakMap: Similar to a Map, but with weaker object references, allowing objects to be garbage
collected if there are no other references to them.
WeakSet: Similar to a Set, but with weaker object references.
How to declare variable in Javascript?
In JavaScript, you can declare a variable using the `var`, `let`, or `const` keywords. Here's how you can
use each of them to declare variables:

 What are arithmetical operators?


1. **Using `var`:**
The `var` keyword was traditionally used for declaring variables in JavaScript. However, it has some
quirks and is less commonly used now due to its scope-related issues.

```javascript
var variableName = value;
```

2. **Using `let`:**
The `let` keyword was introduced in ECMAScript 6 (ES6) to address some of the scope-related
problems of `var`. It's used for declaring variables that can be reassigned.

```javascript
let variableName = value;
```
3. **Using `const`:**
The `const` keyword, also introduced in ES6, is used for declaring variables whose values cannot be
reassigned after initialization. This is useful for creating constants.

```javascript
const constantName = value;
```

Here's an example demonstrating the usage of all three declaration keywords:

```javascript
// Using var
var nameVar = "John";
nameVar = "Alice"; // This is allowed, but generally discouraged due to scope issues

// Using let
let age = 25;
age = 26; // Reassignment is allowed

// Using const
const pi = 3.14159;
// pi = 3.14; // This will result in an error since constants cannot be reassigned
```
What are arithmetical operators?
1. **Addition (`+`):** Adds two values together.
```javascript
const sum = 5 + 3; // Result: 8
```

2. **Subtraction (`-`):** Subtracts the second value from the first.


```javascript
const difference = 10 - 7; // Result: 3
```
3. **Multiplication (`*`):** Multiplies two values.
```javascript
const product = 4 * 6; // Result: 24
```
4. **Division (`/`):** Divides the first value by the second.
```javascript
const quotient = 15 / 3; // Result: 5
```
5. **Modulus (`%`):** Returns the remainder of the division of the first value by the second.
```javascript
const remainder = 17 % 5; // Result: 2 (because 17 divided by 5 is 3 with a remainder of 2)
```

6. **Exponentiation (`**`):** Raises the first value to the power of the second.
```javascript
const power = 2 ** 3; // Result: 8 (2 raised to the power of 3)
```
```javascript
const result = (10 + 5) * 2; // Result: 30 (15 * 2)
```
 write simple javascripts with html for expression evalution and massage printing ?

<!DOCTYPE html>
<html>
<head>
<title>Expression Evaluation</title>
</head>
<body>
<h1>Expression Evaluation</h1>

<label for="expression">Enter an expression:</label>


<input type="text" id="expression">
<button onclick="evaluateExpression()">Evaluate</button>

<p id="result"></p>

<script>
function evaluateExpression() {
const expressionInput = document.getElementById('expression');
const resultParagraph = document.getElementById('result');

const expression = expressionInput.value;


try {
const evalResult = eval(expression);
resultParagraph.textContent = `Result: ${evalResult}`;
} catch (error) {
resultParagraph.textContent = `Error: ${error.message}`;
}
}
</script>
</body>
</html>

You might also like