Lab 3Variables and ConstantsfunctionScoped = 2blockScoped = 5 constant1 = -3 Variables TypesnumberVariable = 123floatingPointNumber = 234.345 stringVariable = Hello World! booleanVariable = true isNumber = number isString = string isBoolean = boolean Boolean Variablestrue1 = truefalse1 = false false2 = false true2 = true true3 = true true4 = true true5 = true false3 = false If Elsetrue1 !false1 Logged InWelcome Welcome If ElsePlease login InlineFunctionsLegacy ES5 functionstwoPlusFour = 6add(2, 4) = 6 New ES6 arrow functionsthreeMinusOne = 2subtract(3, 1) = 2 Implied returnfourTimesFive = 20multiply(4, 5) = 20 Template Literalsresult1 = 2 + 3 = 5result2 = 2 + 3 = 5 greeting1 = Welcome home alice greeting2 = Logged in: No Simple ArraysnumberArray1 = 12345stringArray1 = string1string2 variableArray1 = 25-312345string1string2 Todo list:
Array index and lengthlength1 = 5index1 = 2 Add/remove to/from arraysnumberArray1 = 12456stringArray1 = string1string3 Todo list:
Looping through arraysstringArray2 = STRING1STRING3Map Functionsquares = 149162536cubes = 182764125216 Todos:
Find Functionfour = 4string3 = string3 Find Index FunctionfourIndex = 2string3Index = 1 Filter FunctionnumbersGreaterThan2 = 456evenNumbers = 246 oddNumbers = 15 JSON Stringifysquares = [1,4,16,25,36]Housebedrooms4bathrooms2.5Data{
"bedrooms": 4,
"bathrooms": 2.5,
"squareFeet": 2000,
"address": {
"street": "Via Roma",
"city": "Roma",
"state": "RM",
"zip": "00100",
"country": "Italy"
},
"owners": [
"Alice",
"Bob"
]
}Spread OperatorArray Spreadarr1 = [1,2,3]arr2 = [1,2,3,4,5,6] Object Spread{"a":1,"b":2,"c":3}{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6} {"a":1,"b":4,"c":3} DestructingObject Destructingconst { name, age } = { name: "John", age: 25 }name = John age = 25 Array Destructingconst [first, second, third] = ["one","two","three"]first = one second = two third = three Function Destructingconst add = (a, b) => a + b;const sum = add(1, 2); const subtract = ({ a, b }) => a - b; const difference = subtract({ a: 4, b: 2 }); sum = 3 difference = 2 Destructing Imports
ClassesYellow background Blue background Red background Dynamic Blue background Dangerous background StylesYellow background Red background Blue background Adda = 3 b = 4a + b = 7 Square of 416Lorem ipsum dolor sit amet consectetur adipisicing elit. Suscipit ratione eaque illo minus cum, saepe totam vel nihil repellat nemo explicabo excepturi consectetur. Modi omnis minus sequi maiores, provident voluptates. Todo ListBuy milk (CANCELED) Pickup the kids (IN PROGRESS) Walk the dog (DEFERRED) Client Component DemoCurrent pathname: /labs/lab3 Server Component DemoServer Render TimeRendered on server at: 8:23:09 PM Server Information{
"platform": "linux",
"nodeVersion": "v24.13.0",
"memoryUsage": {
"rss": 123346944,
"heapTotal": 67411968,
"heapUsed": 36161112,
"external": 4109732,
"arrayBuffers": 490919
},
"cwd": "/vercel/path0"
}Filesystem Access Demo[ ".git", ".gitignore", ".next", ".vercel", "README.md", "app", "eslint.config.mjs", "next-env.d.ts", "next.config.ts", "node_modules", "package-lock.json", "package.json", "postcss.config.mjs", "public", "scripts", "tsconfig.json", "vercel.json" ] |