This repository contains my JavaScript learning notes and code examples, organized by sections and lectures. The code is beginner-friendly and covers basics, variables, functions, loops, DOM manipulation, and more. Credit Mosh Hamedani in this video: https://www.youtube.com/watch?v=W6NZfCO5SIk
- Download "VS Code" from here: https://code.visualstudio.com/Download
- Go to the "Extensions" tab and download "Live Server"
- Download all the files from this repositry and open them in VS Code
- Right click on "index.html" and choose "Open with Live Server"
- You can now access the console by right clicking on an empty area, choosing "Inspect" and then enter the console tab.
- You can access the guide in the "script.js" file..
- Introduction
- Values & Variables
- Primitives & Types
- Reference Types
- Functions
- Built-In Functions
- DOM Interaction
Lecture 1 – First Trial
console.log()prints messages in the console.alert()shows popup messages (can be disabled).- Basic math operations:
+,-,*,/,**. - Math shortcuts:
++,--,+=,-=,*=,/=. - Comments:
//for single-line notes. - Strings can use
" ",' ', or backticks` `for template literals. - Escape sequences:
\n,\\,\". - Semi-colons
;end statements (optional but recommended).
Lecture 2 – Variables
- Declare variables using
letorvar(avoidvardue to bugs). - Variables can be assigned later.
- Rules: cannot start with numbers, no spaces/hyphens, case-sensitive.
Lecture 3 – Constants
- Use
constfor permanent variables that cannot change. - Constants inside functions/loops are recreated each execution.
Lecture 4 – Primitive Types
- String, Number, Boolean literals.
- Undefined and Null represent missing values.
- ES6 Symbol: unique values, optionally global with
Symbol.for().
Lecture 5 – Dynamic Typing
- JavaScript is dynamically typed; variable types can change.
- Numbers are all the same type (unlike Java/C++).
Lecture 6 – Objects
- Objects store key-value pairs, like Python dictionaries.
- Access: dot notation
obj.keyor bracket notationobj['key'].
Lecture 7 – Arrays
- Arrays are ordered lists; indexes start at 0.
- Can store different types.
- Length property:
arr.length.
Lecture 8 – Functions
- Declared using
function name(args) {}. - Arguments can be optional (default
undefined). - Functions can return values with
return.
Lecture 9 – Control Flow
- Conditionals:
if,else if,else. - Comparison operators:
==,!=,>,<,>=,<=. - Loops:
while,for,for...of,for...in. breakexits loops early.setTimeout(function, delay, args)schedules delayed execution.
Lecture 10 – Getting Elements
document.getElementById()orgetElementsByClassName()to access HTML elements.
Lecture 11 – Changing Text
element.textContentto change the text of HTML elements dynamically.
Lecture 12 – Detect Button Click
element.addEventListener('click', function)to trigger actions on clicks.- Access input values with
input.value.
Lecture 13 – Creating Elements
document.createElement()to create new HTML elements.- Append with
parent.appendChild(). - Modify properties:
className,style,textContent,src,width,height. setTimeout()can remove elements after a delay.
- This project is for learning purposes and demonstrates basic to intermediate JavaScript concepts.
- All code is commented for clarity and beginner understanding.
- Feel free to experiment and modify examples for practice.
Leo Alon – Beginner JavaScript enthusiast
Mosh Hamedani - Developer on youtube - https://www.youtube.com/@programmingwithmosh