0% found this document useful (0 votes)
25K views12 pages

Lecture42 JSTypes

This document discusses Javascript types, including the Object type which is a collection of name-value pairs, and 6 Primitive types which represent single immutable values. The Primitive types are Boolean, Undefined, Null, Number, String, and Symbol. It explains the key characteristics of each type, such as Boolean only having true or false values, Undefined meaning a variable has been allocated but no value set, and Null signifying lack of value.

Uploaded by

anhle03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25K views12 pages

Lecture42 JSTypes

This document discusses Javascript types, including the Object type which is a collection of name-value pairs, and 6 Primitive types which represent single immutable values. The Primitive types are Boolean, Undefined, Null, Number, String, and Symbol. It explains the key characteristics of each type, such as Boolean only having true or false values, Undefined meaning a variable has been allocated but no value set, and Null signifying lack of value.

Uploaded by

anhle03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

In this lecture, we will discuss

Javascript Types

Types

A type is a par+cular
data structure.
Each language defines some built-in types
Built-in types can be used to build other data structures
JS has 7 built-in types: 6 primitive and 1 Object type

Object Type

Object is a collec+on of
name/value pairs

Object Type
Person Object
name

name

value

firstName: Yaakov,
lastName: Chaikin,
social: {
linkedin : yaakovchaikin,
twitter: yaakovchaikin,
facebook: CourseraWebDev
}
value

Primitive Types

Primi+ve type represents a


single, immutable value
Single value, i.e., not an object
Immutable means once its set, it cant be changed
Value becomes read-only
You can create another value based on an existing one

Primitive Type: Boolean

Boolean can only have


2 values: true or false

Primitive Type: Undefined

Undened signies that no


value has ever been set
Can only have one value: undefined
You can set a variable to undefined,
but you should NEVER do it
Its meaning is that its never been defined, so defining it
to undefined is counter to its core meaning

Primitive Type: Null

Null signies lack of value


As opposed to undefined, which is lack of definition
Can only have one value: null
Its ok to explicitly set a variable to null

Primitive Type: Number

Number is the only numeric


type in Javascript
Always represented under the hood as
double-precision 64-bit floating point
JS does not have an integer type
Integers are a subset of doubles instead of a separate
data type

Primitive Type: String

String is sequence of
characters used to
represent text
Use either single or double quotes, i.e., text or text

Primitive Type: Symbol

Symbol is new to ES6


Not covered in this class

ES6 (released 2015) isnt widely supported or used yet

Summary
Javascript defines 7 built-in types
Object and 6 Primitives

Object type is a collection of name/value pairs


Primitive type can contain a single, immutable value
Undefined means variable memory has been allocated
but no value has ever been explicitly set yet

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy