0% found this document useful (0 votes)
2 views8 pages

JS Lesson - 3 Note

The document explains the concept of variables in JavaScript, describing them as containers for storing various data types. It outlines primitive data types such as numbers, strings, booleans, undefined, and null, as well as objects, which include arrays and functions. Additionally, it highlights that JavaScript is a weakly typed language, allowing for dynamic typing without explicit type declarations, and introduces the 'typeof' operator for checking variable types.

Uploaded by

learncs48
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)
2 views8 pages

JS Lesson - 3 Note

The document explains the concept of variables in JavaScript, describing them as containers for storing various data types. It outlines primitive data types such as numbers, strings, booleans, undefined, and null, as well as objects, which include arrays and functions. Additionally, it highlights that JavaScript is a weakly typed language, allowing for dynamic typing without explicit type declarations, and introduces the 'typeof' operator for checking variable types.

Uploaded by

learncs48
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/ 8

JavaScript

Fundamental
DATA TYPES
📌 What is a variable?
A variable is like a box where you can store
something — like a number, a word, or even a
whole list!
🧩 1) Primitive Data Types
simplest types of values
Examples include:
number - 1, 2, 105, 3.14
string - 'a', "one", 'World Wide Web'
boolean - true, false
undefined - Indicates absence or unknown value
null - Special keyword: value = "none" or "empty"
✅ But variable is still defined
🧱 2) Objects
Anything that’s not a primitive is an object.
Examples are:
An object that stores a person’s details.
Arrays (lists).
Functions (which do something).
JavaScript does not have types for variables
🔸 JavaScript is a weakly typed language:
You don’t declare a variable's type explicitly.
✅ Checking the Type with typeof
Let’s see how to find out the type:
typeof x; // "number"
typeof name; // "string"
typeof michel; // "object"
📝 Recap and Key Takeaways
🎉 Great job! Let’s wrap up:
✅ Variables in JavaScript can store primitive data types or objects.
✅ You don’t have to declare the type — JavaScript figures it out for you!
✅ Use the typeof operator to check what kind of value you have.
✅ Remember: simple = primitive, collections = objects.
👉 Practice:
1️⃣ Create a variable for your age, your name, and whether you are a
student (true or false).
2️⃣ Use typeof to log the type of each variable.

You might also like