JavaScript

JavaScript Fundamentals

Introduction to JavaScript

JavaScript is a high-level, interpreted programming language that conforms to the ECMAScript specification. It is a language that is also characterized as dynamic, weakly typed, prototype-based and multi-paradigm.

Variables and Data Types

JavaScript provides different data types to hold different types of values. There are two types of data types in JavaScript:

  • Primitive data types: String, Number, Boolean, Undefined, Null, Symbol
  • Non-primitive data types: Object

Functions

Functions are one of the fundamental building blocks in JavaScript. A function is a set of statements that performs a task or calculates a value.

JavaScript Flashcards

What is a closure in JavaScript?

A closure is the combination of a function and the lexical environment within which that function was declared.

What is hoisting in JavaScript?

Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.

What is the difference between let and var?

let is block-scoped while var is function-scoped. var can be redeclared while let cannot.

What is an arrow function?

Arrow functions are a concise way to write functions in JavaScript. They don't have their own 'this' binding.

What is a promise in JavaScript?

A promise is an object that may produce a single value some time in the future with either a resolved value or a reason that it's not resolved.

JavaScript Quiz

1. Which of the following is not a JavaScript data type?

  • Boolean
  • String
  • Integer
  • Undefined

2. What will be the output of: console.log(typeof null);

  • null
  • undefined
  • object
  • number

3. Which method is used to add an element at the end of an array?

  • append()
  • push()
  • add()
  • pop()

CSS Fundamentals

Introduction to CSS

CSS (Cascading Style Sheets) is used to style and layout web pages — for example, to alter the font, color, size, and spacing of your content, split it into multiple columns, or add animations and other decorative features.

CSS Selectors

CSS selectors are used to select the HTML elements you want to style. There are several types of selectors:

  • Element selector: selects elements based on the element name
  • ID selector: uses the id attribute of an HTML element
  • Class selector: selects elements with a specific class attribute
  • Attribute selector: selects elements based on an attribute or attribute value

Box Model

All HTML elements can be considered as boxes. The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content.

CSS Flashcards

What does CSS stand for?

Cascading Style Sheets

What is the CSS box model?

The box model is a container that contains multiple properties including borders, margin, padding, and the content itself.

What is the difference between padding and margin?

Padding is the space between the content and the border, while margin is the space outside the border.

What is a CSS pseudo-class?

A pseudo-class is used to define a special state of an element (e.g., :hover, :active, :focus).

What is Flexbox?

Flexbox is a CSS layout module that provides a more efficient way to lay out, align and distribute space among items in a container.

CSS Quiz

1. Which property is used to change the background color?

  • color
  • bgcolor
  • background-color
  • background

2. How do you add a comment in CSS?

  • // this is a comment //
  • /* this is a comment */
  • <!-- this is a comment -->
  • # this is a comment

3. Which property is used to change the font of an element?

  • font-style
  • font-weight
  • font-family
  • text-style

Algorithms Fundamentals

Introduction to Algorithms

An algorithm is a step-by-step procedure to solve a problem or accomplish a task. Algorithms are fundamental to computer science and are used to process data, perform calculations, and automate reasoning.

Algorithm Complexity

Algorithm complexity is a measure of the amount of time and/or space required by an algorithm for an input of a given size (n).

  • Time complexity: Amount of time taken by an algorithm to run
  • Space complexity: Amount of memory used by an algorithm
  • Big O notation: Used to describe the performance or complexity of an algorithm

Common Algorithm Types

There are several types of algorithms used in computer science:

  • Search algorithms: Find specific data in a structure
  • Sort algorithms: Arrange data in a particular order
  • Recursive algorithms: Solve problems by breaking them into smaller subproblems
  • Divide and conquer: Break problem into subproblems, solve them, and combine

Algorithms Flashcards

What is an algorithm?

A step-by-step procedure to solve a problem or accomplish a task.

What does Big O notation describe?

It describes the performance or complexity of an algorithm.

What is the time complexity of binary search?

O(log n)

What is a recursive algorithm?

An algorithm that solves a problem by breaking it into smaller subproblems of the same type.

What is the difference between BFS and DFS?

BFS explores level by level, while DFS explores as far as possible along each branch before backtracking.

Algorithms Quiz

1. Which sorting algorithm has the worst time complexity of O(n²)?

  • Merge Sort
  • Quick Sort
  • Bubble Sort
  • Heap Sort

2. What is the time complexity of accessing an element in an array by index?

  • O(1)
  • O(n)
  • O(log n)
  • O(n²)

3. Which algorithm uses a divide and conquer approach?

  • Bubble Sort
  • Insertion Sort
  • Merge Sort
  • Selection Sort

Data Structures Fundamentals

Introduction to Data Structures

Data structures are specialized formats for organizing, processing, retrieving and storing data. They are essential for creating efficient software algorithms.

Types of Data Structures

Data structures can be classified into two main types:

  • Primitive data structures: Basic structures that are directly operated upon by machine instructions (integers, floats, characters)
  • Non-primitive data structures: Derived from primitive data structures (arrays, lists, stacks, queues, trees, graphs)

Common Data Structures

Some commonly used data structures include:

  • Arrays: Collection of elements identified by array index
  • Linked Lists: Collection of nodes that together form a sequence
  • Stacks: Collection of elements with Last-In-First-Out (LIFO) principle
  • Queues: Collection of elements with First-In-First-Out (FIFO) principle
  • Trees: Hierarchical structure with root value and subtrees of children
  • Graphs: Collection of nodes connected by edges

Data Structures Flashcards

What is a data structure?

A way of organizing and storing data so that it can be accessed and modified efficiently.

What is the main principle of a stack?

Last-In-First-Out (LIFO)

What is the time complexity of searching in a binary search tree?

O(log n) on average, O(n) in worst case

What is the difference between an array and a linked list?

Arrays have fixed size and direct access, while linked lists have dynamic size and sequential access.

What is a hash table?

A data structure that implements an associative array abstract data type, using a hash function to map keys to values.

Data Structures Quiz

1. Which data structure uses FIFO (First-In-First-Out) principle?

  • Stack
  • Queue
  • Tree
  • Graph

2. What is the time complexity of inserting an element at the end of a dynamic array?

  • O(1)
  • O(n)
  • O(log n)
  • O(n²)

3. Which data structure is typically used for implementing recursion?

  • Queue
  • Stack
  • Linked List
  • Tree