-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJavaScript.txt
More file actions
39 lines (31 loc) · 2.57 KB
/
Copy pathJavaScript.txt
File metadata and controls
39 lines (31 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
JavaScript ("JS" for short) is a full-fledged dynamic programming language that can add interactivity to a website. It was invented by Brendan Eich (co-founder of the
Mozilla project), the Mozilla Foundation, and the Mozilla Corporation.
JavaScript is versatile and beginner-friendly. With more experience, you'll be able to create games, animated 2D and 3D graphics, comprehensive database-driven apps, and
much more!
JavaScript itself is relatively compact, yet very flexible. Developers have written a variety of tools on top of the core JavaScript language, unlocking a vast amount of
functionality with minimum effort. These include:
Browser Application Programming Interfaces (APIs) built into web browsers, providing functionality such as dynamically creating HTML and setting CSS styles; collecting and
manipulating a video stream from a user's webcam, or generating 3D graphics and audio samples.
Third-party APIs that allow developers to incorporate functionality in sites from other content providers, such as Twitter or Facebook.
Third-party frameworks and libraries that you can apply to HTML to accelerate the work of building sites and applications.
BASIC HELLO WORLD
<html>
<head>
<script>
const myHeading = document.querySelector('h1');
myHeading.textContent = 'Hello world!';
</script>
</head>
</html>
Save the file with .js extension.
The heading text changed to Hello world! using JavaScript. You did this by using a function called querySelector() to grab a reference to your heading, and then store it in
a variable called myHeading. This is similar to what we did using CSS selectors. When you want to do something to an element, you need to select it first.
Following that, the code set the value of the myHeading variable's textContent property (which represents the content of the heading) to Hello world!.
String This is a sequence of text known as a string. To signify that the value is a string, enclose it in single quote marks. let myVariable = 'Bob';
Number This is a number. Numbers don't have quotes around them. let myVariable = 10;
Boolean This is a True/False value. The words true and false are special keywords that don't need quote marks. let myVariable = true;
Array This is a structure that allows you to store multiple values in a single reference. let myVariable = [1,'Bob','Steve',10];
Refer to each member of the array like this:
myVariable[0], myVariable[1], etc.
Object This can be anything. Everything in JavaScript is an object, and can be stored in a variable. Keep this in mind as you learn. let myVariable = document.querySelector('h1');
All of the above examples too.