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

Introduction To JavaScript Functions Arrays and Objects

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

Introduction To JavaScript Functions Arrays and Objects

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

Introduction to

JavaScript Functions,
Arrays, and Objects

In this presentation, we'll explore the fundamentals of JavaScript, focusing on the


essential building blocks: functions, arrays, and objects. We'll dive into their
definitions, usage, and the various ways to work with them to create powerful
and dynamic web applications.

by Sahil Kshirsagar
Understanding JavaScript Functions

1 What are Functions? 2 Benefits of Functions


Functions are reusable blocks of code Functions promote code reuse, improve
that perform a specific task. They can readability, and make your code more
take in parameters, perform operations, modular and maintainable.
and return values.

3 Calling Functions
Functions are called by their name, followed by parentheses that can contain arguments. The
function's code is then executed.
Function Definition Types with Examples

Function Declaration Function Expression Arrow Functions

Declares a function with a name Assigns a function to a variable, A more concise syntax for
that can be called later in the allowing for anonymous writing functions, especially for
code. functions. single-line operations.

function greet(name) const greet = const greet = (name)


{ function(name) { =>
console.log(`Hello,
console.log(`Hello, console.log(`Hello, ${name}!`);
${name}!`); ${name}!`);
} };
Working with Arrays in JavaScript

1 Array Basics
Arrays are ordered collections of values, which can be of any data type, including
numbers, strings, and objects.

2 Array Manipulation
Arrays provide a variety of built-in methods for adding, removing, and manipulating
elements, such as push(), pop(), and splice().

3 Iterating Over Arrays


You can loop through array elements using various methods like for loops, forEach(),
and map() to perform operations on each item.
Commonly Used Array Methods and
Examples

filter() map() reduce() sort()


Creates a new array Creates a new array Applies a function Sorts the elements of an
with all elements that with the results of against an accumulator array in place and
pass the test calling a provided and each element in the returns the array.
implemented by the function on every array to reduce the array
provided function. element in the calling to a single value.
array.
Introduction to JavaScript Objects
What are Objects? Creating Objects
Objects in JavaScript are collections of key-value Objects can be created using object literals, object
pairs, where the keys are strings, and the values constructors, or Object.create() method.
can be of any data type, including functions.

Accessing Object Properties Modifying Objects


Object properties can be accessed using dot You can add, update, and delete properties of an
notation or bracket notation, depending on the object using assignment operators or built-in
property name. methods like Object.assign() and delete.
Accessing and Manipulating Object Properties

Dot Notation Bracket Notation Adding and Updating


Properties
Use dot notation to access Use bracket notation to access
object properties when the object properties when the You can add new properties or
property name is known and is property name is stored in a update existing ones using the
a valid JavaScript identifier. variable or is a computed assignment operator (=).
expression.
Conclusion and Key Takeaways
1 Functions, Arrays, 2 Mastering array 3 Continuous learning
and Objects are the methods and object and practice
building blocks of property access
JavaScript
JavaScript is an ever-
Exploring the various evolving language, so keep
Understanding how to use built-in methods and exploring new features and
these core concepts is techniques for working best practices to stay up-to-
essential for writing with arrays and objects date and become a more
effective and dynamic will greatly enhance your proficient developer.
JavaScript code. JavaScript skills.

You might also like