0% found this document useful (0 votes)
4 views

JavaScript Exam Notes

Uploaded by

hkmodi0
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

JavaScript Exam Notes

Uploaded by

hkmodi0
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

JavaScript Exam Notes

Variables and Different Types

- Variables are containers for storing data values.

- Use var (old), let (block-scoped), const (constant).

- Examples:

let age = 25;

const pi = 3.14;

Operators and Data Types

- Operators: Arithmetic (+, -, *, /), Comparison (==, ===, !=), Logical (&&, ||, !).

- Data Types: Number, String, Boolean, Undefined, Null, Object, Symbol.

Objects and Events

- Objects: Key-value pairs. Example: let person = {name: "John", age: 30}.

- Events: User interactions like click, hover, keypress. Example:

element.addEventListener("click", function() {...});

String Methods and String Search

- Methods: toUpperCase(), toLowerCase(), slice(), replace(), split().

- Search: indexOf(), includes(), startsWith(), endsWith().

Arrays and Array Methods

- Array: Ordered collection of items.


- Methods: push(), pop(), shift(), unshift(), sort(), reverse(), map(), filter(), reduce().

Switch Case and Control Structures

- Switch: Used for multiple conditions. Example:

switch(expression) { case value: ...; break; default: ...; }

- Control Structures: if-else, for loop, while loop, do-while loop.

Regular Expressions for Validation

- Regular Expressions: Patterns for matching strings.

- Syntax: /pattern/modifiers. Example: /^[a-zA-Z0-9]+$/.

- Validation: Validate emails, passwords, etc.

Calculator Functionality

- Create functions for basic operations: add, subtract, multiply, divide.

- Example:

function add(a, b) { return a + b; }

Fibonacci Series

- Fibonacci: Sequence where each number is the sum of the two preceding ones.

- Example:

function fibonacci(n) {

let fib = [0, 1];

for (let i = 2; i < n; i++) {

fib[i] = fib[i - 1] + fib[i - 2];

}
return fib;

Display in Ascending/Descending

- Use array sort method for sorting.

- Ascending: array.sort((a, b) => a - b).

- Descending: array.sort((a, b) => b - a).

Animation Using jQuery

- jQuery provides easy methods for animation.

- Example:

$("#element").animate({width: "100px", height: "50px"}, 1000);

Handling Events in jQuery

- jQuery methods for events: .click(), .hover(), .on().

- Example:

$("#button").click(function() { alert("Button clicked!"); });

Getter and Setter (Concept)

- Getters: Access object properties. Setters: Modify object properties.

- Example:

let obj = { get value() {...}, set value(v) {...} };

Functions in JavaScript
- Functions: Reusable blocks of code.

- Syntax: function name(parameters) {...}.

- Arrow Functions: const func = (a, b) => a + b.

You might also like