You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/javascript/all-about-variables/hoisting.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ description: Learn about hoisting in JavaScript and how it affects variable decl
9
9
10
10
<AdsComponent />
11
11
12
+
<br />
13
+
12
14
Hoisting is a unique feature of JavaScript that allows you to access variables and functions before they are declared in your code. This behavior can be surprising if you're not familiar with it, so understanding how hoisting works is essential for writing reliable JavaScript code.
13
15
14
16
In this tutorial, we'll explore what hoisting is, how it works in JavaScript, and how it affects variable declarations and function definitions.
@@ -19,6 +21,10 @@ Hoisting is a JavaScript mechanism where variable and function declarations are
19
21
20
22
It's important to note that only the declarations are hoisted, not the initializations. This means that the variable or function is available for use, but its value is `undefined` until the assignment is encountered in the code.
21
23
24
+
<AdsComponent />
25
+
26
+
<br />
27
+
22
28
## How Does Hoisting Work?
23
29
24
30
### Hoisting with Variables
@@ -101,6 +107,10 @@ var sayHello = function () {
101
107
102
108
In this example, the variable `sayHello` is hoisted to the top of the scope, but the function assignment is not. Trying to call `sayHello` before the function assignment results in a `TypeError`.
103
109
110
+
<AdsComponent />
111
+
112
+
<br />
113
+
104
114
### Summary of Hoisting Behavior
105
115
106
116
Here's a summary of how hoisting works in JavaScript:
Copy file name to clipboardExpand all lines: docs/javascript/all-about-variables/variable-declarations.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ description: Learn how to declare variables in JavaScript using the var, let, an
9
9
10
10
<AdsComponent />
11
11
12
+
<br />
13
+
12
14
Variables are an essential part of any programming language, allowing you to store and manipulate data in your code. In JavaScript, variables are declared using the `var`, `let`, or `const` keywords. Each of these keywords has its own characteristics and best practices for usage. In this tutorial, we'll explore how to declare variables in JavaScript and discuss the differences between `var`, `let`, and `const`.
13
15
14
16
## What Are Variables?
@@ -43,6 +45,10 @@ In this example:
43
45
44
46
Now that you understand the concept of variables, let's explore how to declare them using the `var`, `let`, and `const` keywords.
45
47
48
+
<AdsComponent />
49
+
50
+
<br />
51
+
46
52
## Declaring Variables with `var`, `let`, and `const`
47
53
48
54
In JavaScript, you can declare variables using the `var`, `let`, or `const` keywords. Each keyword has its own scope, hoisting behavior, and mutability characteristics. Let's examine the differences between `var`, `let`, and `const` and when to use each one.
@@ -151,6 +157,10 @@ PI = 3.14; // Error: Assignment to constant variable.
151
157
152
158
-**Imagination:** Imagine `const` as a stone tablet with an inscription that cannot be changed once it's been carved. It's a constant reminder of the value it holds.
153
159
160
+
<AdsComponent />
161
+
162
+
<br />
163
+
154
164
## When to Use `var`, `let`, or `const`?
155
165
156
166
Here are some guidelines on when to use `var`, `let`, or `const` in your JavaScript code:
Copy file name to clipboardExpand all lines: docs/javascript/all-about-variables/variable-naming-rules.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ description: Learn about the rules and best practices for naming variables in Ja
9
9
10
10
<AdsComponent />
11
11
12
+
<br />
13
+
12
14
When writing JavaScript code, it's essential to follow consistent naming conventions for variables to improve code readability and maintainability. Variable names should be descriptive, meaningful, and follow certain rules to ensure clarity and avoid conflicts.
13
15
14
16
In this tutorial, we'll cover the essential rules for naming variables in JavaScript, along with examples and tips to help you avoid common mistakes.
@@ -40,6 +42,10 @@ Choosing meaningful and descriptive variable names is crucial for writing clean
40
42
41
43
By following the rules and best practices for naming variables, you can write better code that is easier to maintain, understand, and share with others.
42
44
45
+
<AdsComponent />
46
+
47
+
<br />
48
+
43
49
## Rules for Naming Variables
44
50
45
51
When naming variables in JavaScript, you need to follow certain rules and conventions to ensure consistency and readability. Here are the essential rules for naming variables:
@@ -78,6 +84,10 @@ let _count = 42;
78
84
let $discountRate =0.1;
79
85
```
80
86
87
+
<AdsComponent />
88
+
89
+
<br />
90
+
81
91
### 3. Variable Names Are Case-Sensitive
82
92
83
93
JavaScript variable names are case-sensitive, meaning that `name`, `Name`, and `NAME` are considered different variables. It's essential to be consistent with the casing of variable names to avoid confusion and errors in your code.
@@ -137,6 +147,10 @@ for (let i = 0; i < 10; i++) {
137
147
}
138
148
```
139
149
150
+
<AdsComponent />
151
+
152
+
<br />
153
+
140
154
### 7. Use CamelCase for Multi-Word Variable Names
141
155
142
156
When a variable name consists of multiple words, it's common to use CamelCase to improve readability. In CamelCase, the first word is lowercase, and subsequent words are capitalized. This convention makes variable names easier to read and understand.
@@ -203,6 +217,10 @@ let g_userName = "Alice";
203
217
204
218
By following these rules and best practices for naming variables in JavaScript, you can write clean, readable, and maintainable code that is easy to understand and work with.
205
219
220
+
<AdsComponent />
221
+
222
+
<br />
223
+
206
224
## Summary
207
225
208
226
Naming variables is a fundamental aspect of writing clean and maintainable JavaScript code. By following the rules and best practices outlined in this tutorial, you can improve the readability, consistency, and quality of your codebase. Here's a quick summary of the key points covered:
Copy file name to clipboardExpand all lines: docs/javascript/all-about-variables/variable-scopes.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ description: Learn about the different scopes of variables in JavaScript.
9
9
10
10
<AdsComponent />
11
11
12
+
<br />
13
+
12
14
Understanding variable scope in JavaScript is essential for writing effective and bug-free code. The scope of a variable determines where in your code a particular variable can be accessed or modified. Knowing how scopes work will help you prevent errors and make your code more predictable and maintainable.
13
15
14
16
In this tutorial, we'll explore the different types of scopes in JavaScript, how they work, and how you can use them to control the accessibility of your variables.
@@ -93,6 +95,10 @@ In the example above, `blockVar` is declared inside an `if` block, making it a b
93
95
94
96
Block scope helps you control the visibility and lifetime of variables within specific code blocks, reducing the chances of unintended side effects and making your code more predictable.
95
97
98
+
<AdsComponent />
99
+
100
+
<br />
101
+
96
102
## Shadowing and Variable Scope
97
103
98
104
Shadowing occurs when a variable declared in an inner scope has the same name as a variable in an outer scope. In such cases, the inner variable "shadows" the outer variable, making the outer variable inaccessible within the inner scope.
Copy file name to clipboardExpand all lines: docs/javascript/data-types/primitive-types/number.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ description: Learn about the number data type in JavaScript, how to create numbe
9
9
10
10
<AdsComponent />
11
11
12
+
<br />
13
+
12
14
Numbers are a crucial part of any programming language, and JavaScript is no exception. In JavaScript, numbers are used to perform calculations, manipulate data, and handle various operations. This tutorial will walk you through everything you need to know about numbers in JavaScript, from basic concepts to advanced usage.
In the examples above, `5e6` represents `5` multiplied by `10` raised to the power of `6` (i.e., `5,000,000`), and `5e-6` represents `5` multiplied by `10` raised to the power of `-6` (i.e., `0.000005`).
83
85
86
+
<AdsComponent />
87
+
88
+
<br />
89
+
84
90
## Number Precision
85
91
86
92
JavaScript numbers are precise up to 15 digits. Beyond this, precision may be lost, and the results of calculations might not be what you expect.
The `NaN` value represents a special "not-a-number" value in JavaScript. It is used to denote the result of an invalid mathematical operation, such as dividing zero by zero.
@@ -180,6 +190,10 @@ let number = parseInt("42");
180
190
console.log(number); // Output: 42
181
191
```
182
192
193
+
<AdsComponent />
194
+
195
+
<br />
196
+
183
197
### 4. `parseFloat()`
184
198
185
199
The `parseFloat()` function parses a string and returns a floating-point number.
Copy file name to clipboardExpand all lines: docs/javascript/data-types/primitive-types/string.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ description: Learn about the string data type in JavaScript, how to create strin
9
9
10
10
<AdsComponent />
11
11
12
+
<br />
13
+
12
14
In JavaScript, a string is a sequence of characters enclosed within single or double quotes. Strings are used to represent text data and are one of the primitive data types in JavaScript.
13
15
14
16
## Creating Strings
@@ -51,6 +53,10 @@ let backticks = `Hello, World!`;
51
53
console.log(backticks); // Output: Hello, World!
52
54
```
53
55
56
+
<AdsComponent />
57
+
58
+
<br />
59
+
54
60
## Common String Operations
55
61
56
62
Strings in JavaScript support various operations, such as concatenation, interpolation, and methods for manipulating string data. Here are some common string operations:
Copy file name to clipboardExpand all lines: docs/javascript/data-types/primitive-types/undefined.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ description: Learn about the undefined data type in JavaScript, how to create un
9
9
10
10
<AdsComponent />
11
11
12
+
<br />
13
+
12
14
In JavaScript, `undefined` is a primitive data type that represents an undefined value. When a variable is declared but not assigned a value, it is automatically assigned the value `undefined`.
Copy file name to clipboardExpand all lines: docs/javascript/introduction-to-javascript/history-of-javascript.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ description: JavaScript has a rich history that dates back to the early days of
9
9
10
10
<AdsComponent />
11
11
12
+
<br />
13
+
12
14
JavaScript, the language that powers the dynamic behavior of websites today, has an interesting history that dates back to the early days of the internet. It was created in just **10 days**, but its impact on the web has been profound and long-lasting. JavaScript has evolved significantly over the years, growing from a simple scripting language to a versatile and powerful programming language that is used by millions of developers worldwide. JavaScript was initially developed by **Brendan Eich** in 1995 while he was working at Netscape Communications Corporation.
13
15
14
16
### The Birth of JavaScript: A 10-Day Wonder
@@ -35,6 +37,10 @@ When JavaScript was first released, it was met with skepticism by some developer
35
37
-**2020:** JavaScript remains one of the most popular programming languages in the world, powering the majority of websites and web applications on the internet.
36
38
-**Future:** JavaScript continues to evolve, with new frameworks, libraries, and tools being developed to enhance its capabilities and simplify web development.
37
39
40
+
<AdsComponent />
41
+
42
+
<br />
43
+
38
44
### JavaScript Today: A Ubiquitous Language
39
45
40
46
Today, JavaScript is used by millions of developers worldwide to build a wide range of applications, from simple websites to complex web applications. It has become an essential tool for front-end web development, enabling developers to create interactive, engaging user experiences. JavaScript is also used on the server-side, thanks to technologies like Node.js, allowing developers to build full-stack applications using a single language.
Copy file name to clipboardExpand all lines: docs/javascript/introduction-to-javascript/how-to-run-javascript.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ description: Learn how to run JavaScript code in the browser and in Node.js.
9
9
10
10
<AdsComponent />
11
11
12
+
<br />
13
+
12
14
JavaScript is a versatile language that can be run in various environments. Whether you're creating interactive web pages, building server-side applications, or scripting automation tasks, JavaScript has you covered. In this chapter, we'll explore different ways to run JavaScript, from your browser to the server and beyond.
13
15
14
16
## 1. Running JavaScript in the Browser
@@ -177,6 +179,10 @@ These online editors provide a convenient way to write and run JavaScript code w
177
179
When using online editors, remember that your code runs in a sandboxed environment, so you may encounter limitations compared to running JavaScript locally on your machine.
178
180
:::
179
181
182
+
<AdsComponent />
183
+
184
+
<br />
185
+
180
186
## 4. Running JavaScript in Integrated Development Environments (IDEs)
181
187
182
188
For more advanced JavaScript development, you can use Integrated Development Environments (IDEs) that provide powerful tools, debugging capabilities, and project management features. IDEs offer a comprehensive environment for writing, testing, and deploying JavaScript applications.
Copy file name to clipboardExpand all lines: docs/javascript/introduction-to-javascript/javascript-versions.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,8 @@ description: JavaScript has gone through numerous updates and improvements since
23
23
24
24
<AdsComponent />
25
25
26
+
<br />
27
+
26
28
JavaScript has gone through numerous updates and improvements since its inception in 1995. These updates are officially known as ECMAScript (ES) versions, named after the standard maintained by ECMA International. Understanding these versions and their features is crucial for anyone looking to master JavaScript. Let's explore each significant version of JavaScript, what they introduced, and how they transformed the language.
27
29
28
30
### ECMAScript 1 (ES1) - The Beginning (1997)
@@ -44,6 +46,10 @@ The first official version of JavaScript was standardized as **ECMAScript 1 (ES1
44
46
45
47
ES3 was a significant milestone in JavaScript’s evolution, laying the foundation for modern web development practices. Many of the features introduced in ES3 are still widely used today.
46
48
49
+
<AdsComponent />
50
+
51
+
<br />
52
+
47
53
### ECMAScript 4 (ES4) - The Unreleased Visionary
48
54
49
55
**ECMAScript 4 (ES4)** was an ambitious update that aimed to introduce many advanced features, including classes, modules, and strong typing. However, due to disagreements within the committee and concerns over the complexity of the proposed changes, ES4 was never officially released. Many of its ideas would later influence future versions of JavaScript.
@@ -141,6 +147,10 @@ ES5 was a significant step forward, making JavaScript more reliable, maintainabl
141
147
142
148
ES6 was a game changer, introducing many features that are now considered essential in modern JavaScript development.
143
149
150
+
<AdsComponent />
151
+
152
+
<br />
153
+
144
154
### ECMAScript 2016 (ES7) - Simplicity and Power
145
155
146
156
**ECMAScript 2016 (ES7)**, released in 2016, was a smaller update but still added some valuable features:
@@ -243,6 +253,10 @@ ES8 continued the trend of making JavaScript more powerful and expressive, with
243
253
244
254
ES9 further refined JavaScript’s capabilities, making it easier to work with complex data structures and asynchronous operations.
245
255
256
+
<AdsComponent />
257
+
258
+
<br />
259
+
246
260
### ECMAScript 2019 (ES10) - Refinements and Improvements
247
261
248
262
**ECMAScript 2019 (ES10)**, released in 2019, added useful refinements to JavaScript:
@@ -361,6 +375,10 @@ ES11 introduced features that improved code readability, maintainability, and pe
361
375
362
376
ES12 focused on quality-of-life improvements and developer productivity, making JavaScript code more concise and readable.
363
377
378
+
<AdsComponent />
379
+
380
+
<br />
381
+
364
382
### ECMAScript 2022 (ES13) - Even More Enhancements
365
383
366
384
**ECMAScript 2022 (ES13**), released in 2022, continued the trend of enhancing JavaScript with new features that improve code readability, performance, and ease of use. The additions in ES13 are subtle but impactful, particularly for developers working with large, complex applications.
@@ -495,6 +513,10 @@ ES12 focused on quality-of-life improvements and developer productivity, making
495
513
496
514
This feature enhances regular expression handling by providing more detailed information about matched substrings.
497
515
516
+
<AdsComponent />
517
+
518
+
<br />
519
+
498
520
### Conclusion
499
521
500
522
JavaScript has come a long way since its inception in 1995. Each new version of the language has introduced innovative features and improvements that have transformed the way developers write code. Understanding the evolution of JavaScript and the features introduced in each version is essential for mastering the language and staying up-to-date with the latest trends in web development. By learning about the different ECMAScript versions and their capabilities, you can enhance your skills as a JavaScript developer and build more robust, efficient, and maintainable applications.
0 commit comments