click below
click below
Normal Size Small Size show me how
JS - Week 1
WTWD 310 - Introduction to JavaScript
| Term | Definition | Example |
|---|---|---|
| JS | JavaScript is a high-level, interpreted language used for interactive effects in web browsers. It's a core technology of the Web, along with HTML and CSS, enabling dynamic content, interactive user interfaces, and various web applications. | alert('Hello World!'); |
| High-Level Language | A high-level language is easy for humans to read and write. It abstracts hardware details, letting programmers write instructions naturally. These languages are platform-independent and must be translated into machine code by a compiler or interpreter. | JavaScript Python Java C++ Ruby PHP C# Swift Kotlin Perl etc. |
| DOM | The Document Object Model (DOM) is a programming interface for web documents. It represents the page so programs can change structure, style, & content. The DOM's tree structure lets nodes represent elements, attributes, & text. JavaScript updates pages. | <html><head></head><body></body></html> |
| Syntax | The set of rules that defines a correctly structured JavaScript program. | A simple JS Function showing syntax: function greet(name) { return 'Hello ' + name + '!'; } console.log(greet('Alice')); |
| Statement | A single line of code that performs an action. JavaScript programs are made up of multiple statements. | let message = 'Hello world!'; |
| Function | A block of code designed to perform a particular task. Functions are executed when they are called (invoked). | Defining and Calling a Function: function add(a, b) { return a + b; } console.log(add(2, 3)); |
| Variable | A named storage for data. Variables can hold different data types and can be changed during program execution. | let age = 36; |
| Data Type | The type of data that can be stored in a variable. Common data types in JavaScript include string number boolean object and undefined. | let name = 'Alice'; // string let age = 30; // number let isStudent = true; // boolean let person = {firstName: 'John', lastName: 'Doe'}; // object let x; // undefined |
| Operator | Symbols used to perform operations on variables and values. Common operators include arithmetic comparison and logical operators. | let sum = 10 + 5; // Addition let difference = 10 - 5; // Subtraction let product = 10 * 5; // Multiplication let quotient = 10 / 5; // Division |
| Debugging | The process of identifying and fixing errors or bugs in the code. | Using console.log() to debug: let total = 0; for (let i = 0; i < 5; i++) { total += i; console.log('Current total:', total); // Debugging output } |
| Error | A problem in the code that prevents it from running as expected. Errors can be syntax errors runtime errors or logical errors. | Example of a syntax error due to a missing parenthesis: console.log('Hello world!'); // Missing closing parenthesis |
| Console | A tool used to output messages for debugging purposes. The console.log() method is commonly used to display values and messages. | Example of logging a message to Console: console.log('This is a message.'); |
| Pseudocode | Pseudocode is a simplified description of a program's logic and flow using plain language. It outlines what the code will do, not the actual code. Pseudocode helps programmers plan before coding, focusing on the algorithm's steps without syntax. | // Pseudocode for calculating the sum of the first n natural numbers START SET sum to 0 SET n to the desired number FOR each number from 1 to n ADD the number to sum END FOR PRINT the value of sum END |