# Demo 2: Data Structures and Collections
# Arrays, tuples, objects, and destructuring

# Arrays
let numbers = [1, 2, 3, 4, 5]
let mixed = [1, "hello", true, 3.14]
numbers
mixed

# Array indexing and methods
numbers[0]
numbers[4]
numbers.length()
numbers.push(6)
numbers

# Array operations
let doubled = numbers.map(x => x * 2)
doubled
let sum = numbers.reduce((acc, x) => acc + x, 0)
sum

# Tuples
let point = (10, 20)
let person = ("Alice", 30, true)
point
person

# Tuple access
point.0
point.1
person.0
person.2

# Tuple destructuring
let (x, y) = point
x
y

let (name, age, active) = person
name
age
active

# Objects
let user = {
    name: "Bob", 
    age: 25,
    email: "bob@example.com"
}
user

# Object access
user.name
user["age"]
user.email

# Object destructuring shorthand
let obj = { x, y }
obj

# Nested destructuring
let nested = {
    person: { name: "Carol", age: 28 },
    location: { city: "NYC", country: "USA" }
}
nested
let { person: { name: user_name } } = nested
user_name