Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

Javascript Basics Paper

Uploaded by

joeariascarranza
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Javascript Basics Paper

Uploaded by

joeariascarranza
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Introduction to JavaScript: Basic Knowledge

1. What is JavaScript?
JavaScript is a high-level, interpreted programming language that is one of the
core technologies of the World Wide Web, alongside HTML and CSS. It allows
you to add interactivity and dynamic behavior to websites.

2. Brief History
• Created by Brendan Eich in 1995
• Originally developed for Netscape 2
• Standardized as ECMAScript in 1997
• Continuous evolution with regular updates (e.g., ES6 in 2015)

3. Basic Syntax and Data Types


Variables
let myVariable = 10;
const PI = 3.14159;
var oldWayToDeclade = "Not recommended for new code";

Data Types
• Number
• String
• Boolean
• Undefined
• Null
• Object
• Symbol (added in ES6)

4. Control Structures
Conditional Statements
if (condition) {
// code to execute if condition is true
} else {
// code to execute if condition is false
}

Loops
for (let i = 0; i < 5; i++) {
console.log(i);
}

1
while (condition) {
// code to execute while condition is true
}

5. Functions
function greet(name) {
return `Hello, ${name}!`;
}

// Arrow function (ES6)


const greetArrow = (name) => `Hello, ${name}!`;

6. Objects and Arrays


Objects
let person = {
name: "John",
age: 30,
isStudent: false
};

Arrays
let fruits = ["apple", "banana", "orange"];

7. DOM Manipulation
JavaScript can interact with the Document Object Model (DOM) to dynamically
change the content, structure, and style of a web page.
// Changing HTML content
document.getElementById("demo").innerHTML = "Hello, World!";

// Changing CSS styles


document.getElementById("demo").style.color = "red";

8. Events
JavaScript can respond to user actions and browser events.
document.getElementById("myButton").addEventListener("click", function() {
alert("Button clicked!");
});

2
9. Asynchronous JavaScript
JavaScript can handle asynchronous operations using callbacks, promises, and
async/await syntax.
// Using Promises
fetch('https://api.example.com/data')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

// Using async/await
async function fetchData() {
try {
const response = await fetch('https://api.example.com/data');
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}

10. Resources for Further Learning


• MDN Web Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript
• JavaScript.info: https://javascript.info/
• FreeCodeCamp: https://www.freecodecamp.org/learn/javascript-
algorithms-and-data-structures/

Conclusion
This introduction covers the basic knowledge needed to start with JavaScript.
As you progress, you’ll discover that JavaScript is a powerful and versatile lan-
guage with many advanced features and applications in both front-end and
back-end development.

You might also like