Client Side Programming
using JavaScript
By Komal Singh
Introduction of JavaScript
• JavaScript is a high-level, versatile, and dynamic programming language that is
primarily used for adding interactivity and behavior to web pages.
• It was created by Brendan Eich in 1995 and has since become one of the most
widely used programming languages in the world.
• JavaScript can be used for Client-side developments as well as Server-side
developments.
• JavaScript is both imperative and declarative type of language. JavaScript contains a
standard library of objects, like Array, Date, and Math, and a core set of language
elements like operators, control structures, and statements.
Features of JavaScript
• JavaScript was created in the first place for DOM(document object model)
manipulation. Earlier websites were mostly static, after JS was created dynamic Web
sites were made.
• Functions in JS are objects. They may have properties and methods just like another
object. They can be passed as arguments in other functions.
• Can handle date and time.
• Performs Form Validation although the forms are created using HTML.
• No compiler is needed.
JavaScript in Web Development
• Enhances web pages by adding interactivity.
• Common use cases: form validation, animations, real-time updates.
• Enables client-side scripting.
• Widely supported by browsers
Variables and Datatypes in JavaScript
• JavaScript is an untyped language because in JavaScript the variables can hold any data type
meaning that JavaScript does not have a type declaration and when the variable is created,
we do not need to specify any data type unlike other programming languages like Java,
C#,C++, etc.
• 4 Ways to Declare a JavaScript Variable:
• Using var
• Using let
• Using const
• Using nothing
Datatype
• Primitive data types: The predefined data types provided by JavaScript language
are known as primitive data types. Primitive data types are also known as in-built
data types.
• String
• Number
• Boolean
• Undefined
• Null
Cont..
• Non-primitive data types: The data types that are derived from primitive
data types of the JavaScript language are known as non-primitive data types.
It is also known as derived data types or reference data types.
• An object
• An array
JavaScript Tokens-Identifiers, Keywords,
Literals, Operators, Symbols.
• In JavaScript, tokens are the smallest individual units in the source code. They
include identifiers, keywords, literals, operators, and symbols. Let's break down each
of these JavaScript tokens:
• 1. Identifiers:
• Identifiers are used to name variables, functions, objects, or other user-defined
items.
• Rules for identifiers:
• Must start with a letter (a-z or A-Z), underscore (_), or a dollar sign ($).
• Subsequent characters can also include digits (0-9).
Cont..
• Identifiers are case-sensitive (e.g., ‘myVariable’ is different from ‘myvariable’).
• Cannot be a reserved keyword (e.g. ‘if ’ , ‘function’ , ‘let’ etc.).
• [Link]:
• Keywords are reserved words in JavaScript, which have predefined meanings
and cannot be used as identifiers.
• Examples of keywords: ‘if ’ , ‘else’, ‘while’ , ‘function’, ‘let’ , ‘const’ , ‘class’ ,
‘return’, etc.
3. Literals:
• Literals are fixed values or data that are directly written into the code.
• Numeric Literals: Represent numbers (e.g., ‘21’, ‘3.14’ , ‘-231’)
• String Literals: Represent text(e.g., “hello, world!” , ‘javaScript’ ) .
• Boolean Literals: Represent true or false values (e.g., ‘true’ , ‘false’).
• Array Literals: Represent lists of values (e.g., ‘[1, 2 , 3]’ , ‘[‘apple’ ,
‘mango’]’).
• Object Literals: Represent key-value pairs (e.g., ‘{ name: ‘Krishna’ , age:
40}’.
• Undefined Literal: Represents an uninitialized variable (‘undefined’).
• Null Literal: Represents the absence of any object value (‘null’).
• RegExp Literals: Represent regular expressions (e.g., ‘/pattern/’).
4. Operators:
5. Symbols:
• The JavaScript Symbol is a function that is used to identify the object
properties.
• A Symbol() method always return a unique value.
• A symbol value may be used as an identifier for object properties.
• Symbols are immutable, just like numbers or strings.
• Symbols cannot be typecasted to primitive data types.
• Syntax
• Symbol([description])
ShortNote:
• JavaScript is a programming language.
• It's used for web development, making websites interactive.
• Created by Brendan Eich in 1995.
• Works alongside HTML and CSS.
Thank You.