Introduction to js and ts Flashcards

1
Q

What is JavaScript?

A

A lightweight, interpreted programming language with object-oriented capabilities, commonly used in web pages and capable of running on browsers, servers, and devices with a JavaScript engine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Key Features of JavaScript

A

Single-threaded: Executes one task at a time.
Non-blocking & Asynchronous: Continues execution without waiting for API calls or I/O events.
Concurrent: Overlaps task execution without simultaneous processing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

JavaScript Code Structure

A

Single Statements: End with a semicolon ;.
Variables: Declared using var, let, or const.
-var: Global variables.
-let: Block-scoped, reassignable.
-const: Block-scoped, immutable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Variable Naming Rules

A

Only use letters, digits, $, and _.
Cannot start with a digit.
Case-sensitive.
Cannot use reserved words.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Data Types in JavaScript

A

Primitive Data Types:

String: Textual data.
Number & BigInt: Numbers.
Boolean: Logical values (true/false).
Null: Absence of value.
Undefined: Unassigned variable.

Non-Primitive Data Types:

Object: Keyed collections.
Array: Stores multiple elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Mutable vs. Immutable Types

A

Mutable: Non-primitive types; changes affect all references.
Immutable: Primitive types; changes create a new value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Memory Management

A

Stack: Stores value types (e.g., primitives).
Heap: Stores reference types (e.g., objects).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

String Methods

A

padStart, padEnd, charAt, charCodeAt, split, indexOf, lastIndexOf, search, slice, substring, substr, replace, toUpperCase, toLowerCase, concat, trim

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Template Literals

A

Use backticks (`).
Features: Multiline strings, string interpolation, and HTML escaping.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Numbers & Type Conversion

A

Number Methods:
toString, toExponential, toFixed, toPrecision, valueOf.
Type Conversion:
String to Number: Number(“3.14”) → 3.14
Number to String: String(123) → “123”
Boolean Conversion:
Boolean(1) → true
Boolean(“”) → false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Date Methods

A

Set Methods: setDate, setFullYear, setHours, etc.
Get Methods: getFullYear, getMonth, getDate, Date.now, etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Operators in JavaScript

A

Basic Operators: +, -, *, /, %, **.
Increment & Decrement:
Prefix (++x): Returns updated value.
Postfix (x++): Returns original value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is TypeScript?

A

A superset of JavaScript with static typing, helping catch errors early and improving code maintainability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why Use TypeScript?

A

Improved type safety.
Better readability.
Increased productivity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Getting Started with TypeScript

A

Install via npm or yarn.
Create .ts files.
Write TypeScript code.
Compile to JavaScript using the TypeScript compiler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly