WT Unit 3
WT Unit 3
JavaScript
function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet("World")); // Output: Hello, World!
let person = {
name: "Alice",
age: 30,
isStudent: false
};
console.log(person.name); // Output: Alice
JavaScript
JavaScript
button.addEventListener('click', function() {
alert('Button clicked!');
});
function fetchData() {
return new Promise((resolve, reject) => {
setTimeout(() => {
const success = true; // Simulate success/failure
if (success) {
resolve("Data fetched successfully!");
} else {
reject("Error fetching data.");
}
}, 2000);
});
}
fetchData()
.then(data => console.log(data))
.catch(error => console.error(error))
.finally(() => console.log("Operation complete."));
JavaScript
Version Control with Git: Git is a distributed version control system (VCS) that
tracks changes in source code during software development. It's essential for
collaboration, tracking history, and managing different versions of a project.
o Elements Panel: Inspects and modifies the HTML and CSS of the current
page in real-time. Useful for debugging layout and styling issues.
o Console Panel: Displays JavaScript errors, warnings, and messages logged by
console.log(). Crucial for debugging JavaScript code.
o Sources Panel: Debugs JavaScript code by setting breakpoints, stepping
through code, and inspecting variables.
o Network Panel: Monitors network requests (e.g., fetching images, CSS,
JavaScript files, API calls), showing their status, size, and timing. Essential for
performance optimization.
o Performance Panel: Analyzes the rendering performance of a web page.
o Application Panel: Inspects local storage, session storage, cookies, and
service workers.
o Lighthouse/Audits Panel: Runs audits for performance, accessibility, best
practices, and SEO.