Javascript
/
Fundamentals
- 1 Fundamentals 11
-
Hello World
-
Code structure
-
Use strict
-
Variables
-
Data types
-
Type conversions
-
Maths
-
Comparitions
-
Conditional
-
Loops
-
Functions
- 2 Testing 2
-
Mocha
-
Nested describe
- 3 Objects 4
-
Basics
-
Reference
-
Methods
-
Constructor
- 4 Types 5
-
Primitives
-
Numbers
-
Strings
-
Arrays
-
Json
- 5 Classes 3
-
Constructor
-
Binding
-
Inheritance
/
Hello World
➟
➟
Last update: 13-05-2022
Script
Javascript code can be inserted almost anywhere into an HTML.
<!doctype html>
<html>
<body>
<script>
/**
* The <script> tag is automatically executed
* when the browser processes the tag.
*
* The old HTML standard required a script to have a type.
* It’s not required anymore.
*
* Now, it can be used for JavaScript modules.
*/
alert('Hello, world!'); // alert in browser
console.log('Hello, world'); // message in console
</script>
</body>
</html>
File
If we have a lot of code, we can put it into a file.
<!doctype html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js">
/**
* The browser will download it and store it in its cache.
* Pages that reference the same script will take it from there.
* This reduces traffic and pages are faster.
*/
</script>
</head>
<body>
<p id='content'></p>
<script>
$('#content').text('Hello World');
</script>
</body>
</html>
➥ Questions github Fundamentals