Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Theory Questions #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Assignment Day-7/AssignmentOne.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Assignment Day-7

## 1. What are anonymous functions in JavaScript?
"Anonymous" as the name suggests, is something that does not have any "name" or "identity". Anonymous functions in JavaScript are functions that do not have any name.

```
// Example:
let greeting = function(name) {
return `Hello, ${name}!`;
};

console.log(greeting("John")); // Output: Hello, John!
```

## 2. Explain strict comparison and Abstract comparison in JavaScript?
Abstract equality will attempt to resolve the data types via type coercion before making a comparison. Strict equality will return false if the types are different.

```
console.log(3 == "3"); // true
console.log(3 === "3"); // false.
```

## 3. Difference between arrow functions and regular functions?

| Feature | Arrow Functions | Regular Functions |
|------------------------|--------------------------------------|--------------------------------------|
| Syntax | Uses arrow (`=>`) syntax. | Uses the `function` keyword. |
| Binding of `this` | Lexical binding: `this` is inherited| Dynamic binding: `this` is determined|
| | from the surrounding lexical context.| by how the function is called. |
| Arguments object | No `arguments` object. | Has an `arguments` object that |
| | | contains all passed arguments. |
| Use of `new` keyword | Cannot be used as constructors. | Can be used as constructors. |
| Usage of `super` | Does not have `super` keyword binding.| Has `super` keyword binding. |
| Implicit return | Automatically returns single expression | Requires explicit `return` statement |
| | results without using `return`. | to return a value. |

## 4.What is Hoisting in JavaScript?
Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution.

```
console.log(x); // Output: undefined
var x = 10;
```
## 5.JavaScript is a garbage collected programming language, explain how?