Introduction to JavaScript – Getting
Started with Basics
What is JavaScript?
• Dynamic programming language
• Used in web development
• Runs in browser
JavaScript in Action (Example)
• HTML snippet with onclick buttons
• Functions: showMessage() and
changeBackgroundColor()
Key JavaScript Elements
• let, const, or var – variable declaration
• Functions & DOM manipulation
Welcome Alert & Button Demo
• alert("Welcome!") on load
• Changing text with innerText
Color Changing Example
• Random background color change
• Use of arrays and Math.random()
JavaScript vs Python – Numbers
Concept JavaScript Python
Variable Declaration let x = 5 x=5
Division 5 / 2 = 2.5 5 / 2 = 2.5 and //
Power x ** y, Math.pow x ** y
Square Root Math.sqrt(9) math.sqrt(9)
Common Number Functions
• Math.round(), Math.floor(), Math.abs()
• Example outputs from JS
Infinity & NaN
• 1 / 0 = Infinity
• "abc" * 2 = NaN
Summary
• JavaScript basics, syntax, and number
operations
• Comparison with Python