Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Last active August 31, 2022 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techthoughts2/813e7413f85ca388d3540577cc984281 to your computer and use it in GitHub Desktop.
Save techthoughts2/813e7413f85ca388d3540577cc984281 to your computer and use it in GitHub Desktop.
tbd - notes taken while learning Javascript
console.log('Hello World')
//#region variables
/*
Cannot be a reserved keyword
Cannot start with a number
Cannot contain space or hyphen
Are case sensitive
*/
// declare a variable
let userName = 'Jake'
console.log(userName)
let firstName = 'Test1'
let FirstName = 'Test1'
// ^ these are different because of case
let interestRate = 0.3
interestRate = 1
console.log(interestRate)
// this will not work because constant
const interestRateConst = 0.3
// interestRateConst = 2
//#region primitives
// string, number, boolean, undefined, null
let myName = 'Jake' //string
let age = 38 //number
let isApproved = true //boolean
let zeName = undefined //undefined
let selectedColor = null
//#endregion
//#endregion
//#region reference types
// object, array, function
// object
let example = {} //object literal
let person = {
name: 'Jake',
age: 38
}
console.log(person)
// dot notation
person.age
person.name = 'Joey'
// bracket notation
person['name'] = 'Mary'
// array
let someColors = [] // empty array
let selectedColors = ['red', 'blue'] // empty array
selectedColors[2] = 'green'
console.log(selectedColors[0])
// functions
function greet(firstName, lastName) {
console.log('Hello ' + firstName + ' ' + lastName)
}
greet('Jake', 'Smith')
// calculates a value
function square(number) {
return number * number
}
let number = square(2)
console.log(number)
//#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment