Day 02 variables and data types in javascript 40 days of js

preview_player
Показать описание
40 days of javascript: day 02 - variables and data types

welcome to day 2 of our javascript journey! today, we're diving into the fundamental concepts of **variables** and **data types**. these are the building blocks of any javascript program. understanding them thoroughly is crucial for writing effective and bug-free code.

**what we'll cover:**

1. **variables:**
* what are variables and why do we need them?
* declaring variables: `var`, `let`, and `const`
* variable naming conventions
* scope of variables: global vs. local
* hoisting

2. **data types:**
* primitive data types:
* string
* number
* boolean
* null
* undefined
* symbol (es6)
* bigint (es2020)
* non-primitive data types (reference types):
* object
* array
* function

3. **typeof operator**
4. **type conversion**

let's get started!

1. variables

**what are variables?**

imagine a variable as a container or a named storage location in your computer's memory. it holds a value that you can refer to and manipulate throughout your program. we need variables because we often need to store data temporarily (like user input, calculation results, or configuration settings) and use that data later. without variables, we'd have to work directly with memory addresses, which would be incredibly cumbersome and error-prone.

**declaring variables: `var`, `let`, and `const`**

javascript offers three keywords to declare variables: `var`, `let`, and `const`. each has its own characteristics, particularly regarding scope and mutability (whether the value can be changed).

* **`var` (function-scoped or globally scoped):**

* `var` was the original way to declare variables in javascript.
* it has *function scope*. this means that if you declare a variable with `var` inside a function, it's only accessible within that function (including any nested functions ...

#JavaScript #Variables #numpy
variables
data types
JavaScript
primitive types
reference types
strings
numbers
booleans
undefined
null
arrays
objects
type conversion
type checking
let
const
Рекомендации по теме