JavaScript Basic

JavaScript is a versatile, high-level programming language primarily used for creating dynamic and interactive content on websites. Key aspects include:
- Client-Side Scripting: JavaScript runs in the browser, enabling interactive web pages without needing to reload the page.
- Syntax: Similar to C-based languages, using variables (
let
,const
), functions, and control structures (if-else, loops). - DOM Manipulation: JavaScript can modify HTML and CSS to update content and styles dynamically.
- Event Handling: It responds to user actions like clicks, keyboard input, and other events.
- Data Types and Structures: Supports numbers, strings, booleans, objects, arrays, null, and undefined.
- Interoperability: Integrates well with other web technologies like HTML and CSS, and can also interact with APIs.
JSHome
The most widely used programming language globally is JavaScript.
JavaScript is a versatile, high-level programming language commonly used for creating interactive and dynamic web content, enabling features like animations, form validations, and real-time updates in web applications.
JS Where To" refers to resources or documentation that guide developers on where to effectively use JavaScript within web development, including its integration with HTML and CSS, as well as frameworks and libraries.
JavaScript in the <head> refers to placing JavaScript code or script references within the <head> section of an HTML document, allowing for code execution before the body content is loaded, which can affect page loading and rendering behavior.
External JavaScript refers to JavaScript code that is written in a separate .js file and linked to an HTML document using the <script> tag, enabling code reuse and better organization while improving page load times.
JavaScript Output refers to the various methods used to display data, such as modifying HTML content with innerHTML, writing directly with document.write(), showing alerts with window.alert(), and logging to the console with console.log().
Using innerHTML
in JavaScript allows you to modify or insert content into an HTML element by directly setting or updating its inner HTML markup.
Using window.alert() in JavaScript displays a pop-up dialog box with a specified message, requiring the user to click "OK" to proceed.
JavaScript statements are instructions that perform actions, such as declaring variables, executing functions, or controlling program flow, and are typically separated by semicolons.
In JavaScript, semicolons are used to separate and terminate statements, ensuring proper code execution and preventing errors in certain situations.
In JavaScript, white space refers to spaces, tabs, and newlines used to improve code readability, which is ignored by the JavaScript engine during execution.
JavaScript keywords are reserved words that have special meanings and are used to perform specific actions, such as var, let, if, function, and return.
JavaScript syntax refers to the set of rules and structure that defines how JavaScript code is written and interpreted, including the use of variables, operators, statements, and functions.
JavaScript expressions are combinations of values, variables, and operators that produce a result or value when evaluated.
JavaScript identifiers (or names) are names given to variables, functions, classes, and other entities, following specific rules that allow for letters, digits, underscores, and dollar signs, but must not begin with a digit or be a reserved keyword.
JavaScript is case-sensitive, meaning that identifiers like variable names, function names, and keywords are distinguished by uppercase and lowercase letters.
JavaScript comments are non-executable lines in the code that provide explanations or notes, using // for single-line comments and /* ... */ for multi-line comments.
Multi-line comments in JavaScript are blocks of text that can span multiple lines, enclosed between /*
and */
, and are ignored by the interpreter.
Using comments prevents code execution by treating the commented lines as non-executable text.
JavaScript variables are named containers used to store data values, which can be declared using var, let, or const.
An example using var
declares a variable with function or global scope, such as var x = 10;
.
An example using const
declares a block-scoped constant, such as const x = 10;
.
JavaScript identifiers are names used to label variables, functions, or objects, following specific naming rules.
The assignment operator (=
) in JavaScript assigns a value to a variable.
JavaScript data types define the kinds of values a variable can hold, such as numbers, strings, objects, and booleans.
One statement can declare multiple variables by separating them with commas, such as let x = 10, y = 20, z = 30;
.
An undefined value indicates that a variable has been declared but not assigned a value.
JavaScript arithmetic refers to mathematical operations like addition, subtraction, multiplication, division, and modulus performed on numbers.
let
is a JavaScript keyword used to declare block-scoped variables that can be reassigned.
Global scope refers to the context in which variables or functions are accessible throughout the entire program, outside of any specific function, block, or module.
Redeclaring variables means defining a variable with the same name again in the same scope, potentially overwriting its previous value or causing errors, depending on the programming language.
var
, let
, and const
are JavaScript keywords used to declare variables, each with different scoping and usage rules.
Good is the quality of being morally right, beneficial, or desirable.
Redeclaring means defining a variable or function with the same name again within the same scope.
Let hoisting refers to the behavior where variables declared with let
are hoisted to the top of their scope but remain in a "temporal dead zone" until initialized.
const is a JavaScript keyword used to declare block-scoped variables whose values cannot be reassigned after their initial assignment.
JavaScript operators are special symbols that perform operations on variables and values, such as arithmetic, comparison, logical, and assignment operations.
JavaScript arithmetic operators perform mathematical operations on numbers, including addition, subtraction, multiplication, division, and modulus.
Arithmetic operations are mathematical calculations involving operators like addition, subtraction, multiplication, division, and modulus.
Adding is the arithmetic operation of combining two or more values to calculate their total sum.
Multiplying is the arithmetic operation of increasing a value by a specified number of times, typically using the multiplication operator (*).
The remainder is the amount left over after division when one number is divided by another.
Decrementing is the process of reducing a value, typically by one, in a stepwise fashion.
Operator precedence is the order in which operators are evaluated in an expression, determining the sequence of operations.
JavaScript assignment operators assign values to variables, with =
being the most common for basic assignments.
JavaScript data types are classifications of values, including primitive types like numbers, strings, booleans, null
, undefined
, and symbol
, as well as the object type for complex data structures.
Data types define the kind of data that can be stored in a variable, such as integers, floating-point numbers, or strings.
JavaScript strings are sequences of characters used to represent text, enclosed in single, double, or backticks.
JavaScript functions are reusable blocks of code designed to perform a specific task, defined using the function
keyword or arrow syntax, and can accept parameters and return values.
Function invocation is the process of calling or executing a function in a program to perform its defined task.
A JavaScript object is a collection of key-value pairs that represents complex data structures, allowing for the grouping of related data and functionality.
JavaScript variables are containers used to store data values, which can be referenced and manipulated throughout the code.
JavaScript object definition is the process of creating a collection of key-value pairs, where keys are strings and values can be any data type.
Object properties are key-value pairs that store data or characteristics of an object in JavaScript.
Accessing object properties involves retrieving the values associated with a specific key in an object, using dot notation or bracket notation.
In JavaScript, objects are fundamental structures that store and organize data, serving as the core building blocks of most applications.
JavaScript primitives are basic data types, including strings, numbers, booleans, null, undefined, and symbols, that are immutable and not objects.
Immutable refers to an object or value that cannot be changed after it is created.
JavaScript objects are mutable, meaning their properties can be changed or updated after they are created.
JavaScript object properties are key-value pairs that define the characteristics and behaviors of an object, allowing access and manipulation of its data.
JavaScript object methods are functions defined within an object that operate on the object's properties, enabling behavior related to that object.
Accessing object methods involves calling a function defined as a property of an object using dot notation or bracket notation.
JavaScript objects display their properties and methods using various techniques, such as console.log(), JSON.stringify(), or by directly accessing them in the browser's developer tools.
A JavaScript object constructor is a special function used to create and initialize objects, typically defined with a capitalized name and using the new keyword to instantiate new objects.
JavaScript events are actions or occurrences detected by the browser, such as user interactions (clicks, key presses) that can trigger specified functions or responses in the code.
Common HTML events are user or browser actions, such as clicks, loading, key presses, and mouse movements, that trigger specific behaviors.
JavaScript strings are sequences of characters used to represent text, defined within single quotes, double quotes, or backticks, and can include various characters and escape sequences.
String length in JavaScript refers to the number of characters in a string, accessed using the .length
property.
In JavaScript, strings can be defined as objects using the String constructor with the new keyword.
JavaScript string methods are built-in functions that allow manipulation and transformation of string values, such as length
, substring()
, and toUpperCase()
.
JavaScript string padding adds characters to the beginning or end of a string to achieve a specified length.
The JavaScript lastIndexOf()
method returns the last occurrence index of a specified substring within a string, or -1 if not found.
The search()
method in JavaScript searches a string for a match against a regular expression and returns the index of the first match.
The matchAll()
method in JavaScript returns an iterator of all matches for a regular expression in a string, including capturing groups.
JavaScript string search methods locate the position of a substring within a string, returning its index or a boolean value.
JavaScript template strings are string literals that allow embedded expressions, multi-line strings, and interpolation using backticks (`).
In JavaScript, a number is a data type representing both integer and floating-point values, capable of performing arithmetic operations.
Integer precision refers to the maximum number of digits an integer can accurately represent in a programming language or system.
Numeric strings are string values that consist of digits and can represent numbers but are treated as text in JavaScript.
NaN (Not a Number) is a JavaScript value representing an invalid or undefined numerical result.
Infinity in JavaScript represents a value greater than any finite number, occurring from division by zero or overflow.
Hexadecimal is a base-16 numbering system using digits 0-9 and letters A-F to represent values.
BigInt is a JavaScript data type that enables representation and manipulation of integers larger than the Number type's maximum safe integer limit.
BigInt operators in JavaScript are used for performing arithmetic, comparison, and bitwise operations on BigInt
values, ensuring precision for arbitrarily large integers.
BigInt is a JavaScript data type that enables representation and manipulation of integers larger than the Number type's maximum safe integer limit.
The Number()
method in JavaScript converts a value to a number type, returning NaN
if the conversion is invalid.
JavaScript number properties are built-in constants and methods associated with the Number type, including Number.MAX_VALUE
, Number.MIN_VALUE
, and various mathematical functions.
JavaScript arrays are ordered collections of elements that can store multiple values, which can be of different types, accessible by their index.
The Number()
method in JavaScript converts a value to a number type, returning NaN
if the conversion is invalid.
Array elements in JavaScript can be objects, allowing arrays to store complex data types alongside primitives.
Adding array elements involves using methods like push()
to add at the end, unshift()
to add at the beginning, or by assigning values to specific indices.
The new Array()
constructor in JavaScript creates a new array, optionally initializing it with specified elements or a set length.
JavaScript array methods are built-in functions that allow for manipulation and interaction with arrays, such as adding, removing, or transforming elements.
The length
property of a JavaScript array returns the total number of elements in the array and can also be used to resize it.
The at()
method in JavaScript retrieves an array element at a specified index, supporting positive and negative indexing.
Popping removes the last element from an array, while pushing adds one or more elements to the end of the array.
Shifting elements in JavaScript involves using the shift()
method to remove the first element of an array, shifting the remaining elements forward.
Changing elements in JavaScript arrays is done by directly assigning a new value to a specific index (e.g., array[index] = value
).
Merging arrays in JavaScript is done using the concat()
method or the spread operator (...
), combining two or more arrays into one.
Flattening an array transforms a nested array into a single-dimensional array by removing all nested structures.
The splice()
method in JavaScript changes the contents of an array by removing, replacing, or adding elements at a specified index.
Using splice()
to remove elements in JavaScript involves specifying the start index and the number of elements to remove from the array.
The slice()
method in JavaScript returns a shallow copy of a portion of an array, selected from a start index to an end index, without modifying the original array.
The automatic toString()
method in JavaScript is called when an object is used in a context that requires a string, converting the object to its string representation.
JavaScript array search methods locate elements within an array, returning their index or a boolean value, using techniques like indexOf, find, and includes.
JavaScript array sort methods arrange the elements of an array in a specified order, typically ascending or descending, using the sort()
function.
Sorting an array in JavaScript is done using the sort()
method, which arranges elements in ascending or descending order based on a specified comparator.
Numeric sort in JavaScript arranges array elements in numerical order, typically using the sort()
method with a custom comparator to handle numerical comparison.
The compare function in JavaScript is used with sorting methods like sort()
to define the order of elements based on custom comparison logic.
Sorting an array in random order in JavaScript can be done by using the sort()
method with a random comparator function, such as Math.random()
.
A stable array sort()
in JavaScript preserves the relative order of elements with equal values during sorting.
The Fisher-Yates method is an efficient algorithm for randomly shuffling the elements of an array, ensuring each permutation is equally likely.
You can find the minimum or maximum value in an array by using sort()
to arrange the elements, then selecting the first (min) or last (max) element.
Math.min()
can be used on an array by spreading the array into individual arguments, like Math.min(...array)
, to find the minimum value.
The JavaScript Array Minimum Method finds the smallest value in an array, commonly using Math.min(...array)
or a custom reduce()
function.
JavaScript array iteration refers to the process of traversing through each element of an array to perform operations, commonly using methods like forEach, map, or reduce.
The map()
method in JavaScript creates a new array by applying a provided function to each element of the original array.
The reduce()
method in JavaScript executes a reducer function on each array element to produce a single accumulated result.
JavaScript array sort methods arrange the elements of an array in a specified order, typically ascending or descending, using the sort()
function.
In JavaScript, const is a declaration that creates a block-scoped variable that cannot be reassigned, commonly used for defining arrays that should not be redefined, although their contents can still be modified.
Browser support indicates the compatibility of a web technology, method, or feature across different browsers and their versions.
Browser support indicates the compatibility of a web technology, method, or feature across different browsers and their versions.
JavaScript dates represent specific moments in time, encapsulated in the Date
object, which provides methods for date and time manipulation and formatting.
JavaScript date formats refer to various ways of representing dates and times as strings, including ISO 8601, locale-based formats, and custom patterns.
ISO dates with year and month are formatted as YYYY-MM
, representing a specific month in a given year.
Time zones are regions of the Earth that have the same standard time, typically based on the offset from Coordinated Universal Time (UTC).
JavaScript date get methods retrieve specific components of a date, such as the year, month, day, hour, and more, using functions like getFullYear(), getMonth(), and getDate().
JavaScript date set methods modify specific components of a date object, such as the year, month, day, and time, using functions like setFullYear(), setMonth(), and setDate().
JavaScript Math is a built-in object that provides a collection of static methods and properties for performing mathematical calculations and operations.
JavaScript random refers to generating pseudo-random numbers, typically using Math.random(), which produces a floating-point number between 0 (inclusive) and 1 (exclusive).
JavaScript booleans are a data type that can hold one of two values: true or false, commonly used for conditional logic.
JavaScript Booleans as objects are created using the Boolean
constructor, allowing for object-like behavior rather than primitive values.
JavaScript comparison refers to evaluating the relationship between two values using operators like ==, ===, !=, and !==, determining their equality or inequality.
The Nullish Coalescing Operator (??) returns the right-hand operand when the left-hand operand is null or undefined, providing a way to set default values.
The JS if-else statement allows for conditional execution of code blocks based on whether a specified condition evaluates to true or false.
The JS switch statement allows for multi-case conditional execution, evaluating an expression and executing the corresponding block of code for the matching case.
The break
keyword is used to exit a loop or switch statement prematurely, transferring control to the statement immediately following it.
Switching details refer to the use of the switch statement in programming to handle multiple conditional branches based on specific values or expressions.
The JS for loop is a control structure that repeatedly executes a block of code a specified number of times, using an initialization, condition, and increment/decrement expression.
A for
loop is a control flow statement that iterates over a sequence (like a range, array, or object properties) or repeats a block of code a specified number of times.
In programming, Expression 1 in a for
loop is the initialization step, where variables are set before the loop starts.
Loop scope refers to the accessibility of variables defined within a loop, which are typically limited to the loop itself and cannot be accessed outside of it.
The JS for/in loop iterates over the enumerable properties of an object, allowing you to access each key in the object.
The for...of
loop in JavaScript iterates over iterable objects (like arrays, strings, or sets), allowing access to each element's value directly.
The while loop in JavaScript repeatedly executes a block of code as long as a specified condition is true.
The break
statement in JavaScript terminates the nearest enclosing loop or switch statement, allowing control to move to the next statement following the loop or switch.
JavaScript labels are identifiers used to name loops or blocks, allowing control statements like break
and continue
to refer to them.
In JavaScript, iterables are objects that implement the Symbol.iterator method, allowing them to be iterated over using loops like for...of.
Iterating over a Set
means looping through its elements using methods like for...of
, forEach()
, or iterators.
JavaScript iterators are objects that allow traversing through a collection, providing the ability to access each element one by one, using methods like next()
.
A homemade iterable in JavaScript is an object that implements the Symbol.iterator
method, allowing it to be used in for...of
loops or with iterators.
In JavaScript, Sets are collections of unique values, where each value can occur only once, and they are iterable and maintain insertion order.
JavaScript Set methods include add(), delete(), has(), and clear(), which allow you to add, remove, check for values, and clear the Set, respectively.
In JavaScript, Maps are collections of key-value pairs where keys can be of any type and maintain the insertion order.
Maps are collections of key-value pairs where keys can be of any data type, unlike objects which use strings as keys.
JavaScript Map methods are functions that allow you to manipulate and interact with key-value pairs in a Map object, such as set
, get
, has
, delete
, clear
, and forEach
.
The Map.entries() method returns an iterator containing all key/value pairs in a Map as an array of arrays.
In JavaScript, objects can be used as keys in Maps, but not in regular objects, as object keys are automatically converted to strings.
Map.groupBy()
is a method (commonly in libraries) that groups elements of a collection by a specified key or property, creating a Map where each key maps to an array of grouped elements.
typeof in JavaScript is an operator used to determine the data type of a given value, returning a string that indicates the type.
The instanceof
operator in JavaScript checks if an object is an instance of a specified class or constructor function.
Empty values in JavaScript refer to values like undefined
, null
, ""
(empty string), 0
, and NaN
, which represent the absence or lack of meaningful data.
The constructor
property is a reference to the function that created an instance's prototype, allowing you to identify the object’s constructor.
All together" refers to bringing multiple elements, actions, or people into a unified or collective state or group.
JavaScript type conversion is the process of converting a value from one data type to another, either explicitly through functions or implicitly during operations.
JS destructuring is a syntax that enables extracting values from arrays or properties from objects and assigning them to variables in a concise manner.
Array destructuring is a syntax that allows unpacking values from an array into individual variables in a concise manner.
JavaScript bitwise operations manipulate individual bits of numeric values using operators such as AND, OR, XOR, NOT, and bit shifts.
JavaScript uses 32-bit signed integers for bitwise operations, treating operands as 32-bit values regardless of their original size.
The JavaScript Bitwise AND (&
) operator performs a bit-by-bit AND operation between two integers, returning a new integer where each bit is 1 only if both corresponding bits are 1.
The JavaScript zero-fill right shift operator (>>>
) shifts bits to the right, filling in zeros from the left, and discards the rightmost bits.
A JavaScript RegExp (Regular Expression) is an object that defines a pattern for matching text in strings, enabling search, replace, and other text manipulation operations.
Using string methods in JavaScript allows you to manipulate and perform operations on strings, such as split()
, replace()
, toUpperCase()
, and substring()
.
In JavaScript, precedence refers to the order in which operators are evaluated in an expression, determining which operations are performed first.
In JavaScript, errors are issues that occur during the execution of a program, preventing it from running as expected, such as syntax errors, runtime errors, or logical errors.
JavaScript try
and catch
are used to handle exceptions, where try
executes code and catch
handles any errors that occur within the try
block.
The throw
statement in JavaScript is used to explicitly raise an error, allowing custom error handling within a program.
The Error object in JavaScript represents an error that occurs during the execution of a program, providing properties like message
, name
, and stack
for debugging.
In JavaScript, scope refers to the context in which variables and functions are accessible or defined, determining their visibility and lifetime within the code.
Local scope in JavaScript refers to the area within a function where variables are defined and accessible only within that function.
Function scope in JavaScript refers to the context in which variables and functions are accessible within a specific function, and are not accessible outside it.
Global scope in JavaScript refers to the context in which variables and functions are accessible throughout the entire program, outside of any function.
Strict mode in JavaScript is a way to opt into a stricter version of JavaScript that enforces safer coding practices and catches common errors, such as disallowing the use of undeclared variables.
A warning in JavaScript is a message indicating a potential issue or best practice violation without stopping the execution of the program.
JavaScript hoisting is the behavior where variable and function declarations are moved to the top of their scope during the compilation phase, before the code is executed.
The let
keyword in JavaScript declares a block-scoped variable, while const
declares a block-scoped, read-only constant.
In JavaScript, variable initializations using let
and const
are not hoisted, meaning they are not accessible before their declaration in the code.
JavaScript Strict Mode is a way to opt-in to a restricted variant of JavaScript that helps catch common coding errors and prevents the use of potentially unsafe features.
In JavaScript, the this
keyword refers to the context or object that calls the function, and its value is determined by how the function is invoked.
Function borrowing is the practice of using a method from one object on another object, typically by using call() or apply() to borrow the method's functionality.
A JavaScript arrow function is a concise syntax for writing functions, using the =>
syntax, and it lexically binds the this
value from its surrounding context.
An arrow function with parameters in JavaScript is a concise syntax for defining functions, written as (param1, param2) => expression
.
In JavaScript, this
refers to the context in which a function is executed and varies based on how the function is called.
JavaScript classes are a blueprint for creating objects, providing a more structured way to define and manage object properties and methods, introduced in ES6.
JavaScript modules are a way to structure and organize code by splitting it into separate files, allowing you to export and import functions, objects, or variables between them.
import is a JavaScript statement used to bring in functions, objects, or values from external modules or files.
JavaScript Object Notation (JSON) is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate. It is commonly used to store and exchange data between a server and a client.
JSON syntax rules include using key-value pairs, enclosing keys and string values in double quotes, and separating pairs with commas within curly braces {}
.
JSON arrays are ordered lists of values enclosed in square brackets []
, where values can be strings, numbers, objects, arrays, true
, false
, or null
.
JavaScript debugging is the process of identifying, diagnosing, and fixing errors or issues in JavaScript code to ensure it runs as expected.
Setting breakpoints in debugging marks specific lines in code to pause execution, allowing inspection of variable states and program flow.
A JavaScript style guide is a set of conventions and best practices for writing consistent, readable, and maintainable code.
Line length < 80 refers to the coding convention of limiting the length of each line of code to 80 characters for better readability and maintainability.
Loading JavaScript in HTML is done using the <script>
tag, either inline or by referencing an external file with the src
attribute.
Using lowercase file names ensures consistency and avoids issues in case-sensitive file systems.
JavaScript best practices are a set of guidelines and techniques that promote writing clean, efficient, maintainable, and error-free code.
Use === for comparison in JavaScript to ensure both value and type equality, avoiding type coercion.
JavaScript mistakes are errors or misunderstandings in code that lead to unintended behavior, often due to incorrect syntax, logic, or misuse of language features.
Confusing addition and concatenation in JavaScript occurs when the +
operator is used with both numbers and strings, leading to unintended results.
You need to use a backslash if you want to break a statement within a string.
An explanation clarifies or simplifies a concept, process, or idea to make it easier to understand.
Accessing arrays with named indexes is not directly possible in JavaScript, as arrays use numeric indices, but objects can be used with named keys for similar functionality.
"Undefined" represents an uninitialized variable, while "null" is an explicit assignment to indicate the absence of a value in JavaScript.
JavaScript performance refers to how efficiently JavaScript code executes in terms of speed, memory usage, and resource optimization within a web environment.
Reducing DOM access in JavaScript improves performance by minimizing the number of interactions with the DOM, which can be slow, especially in large documents.
JavaScript reserved words are keywords that have a predefined meaning in the language and cannot be used as variable, function, or object names.
JS Versions
JavaScript version refers to the specific release or iteration of the language, with each version introducing new features, syntax, and improvements (e.g., ECMAScript 5, ECMAScript 6, ES2020).
JavaScript 2009 (ES5) introduced significant improvements, including strict mode, better array handling, JSON support, and new methods for objects and arrays.
Array.isArray() is a JavaScript method that checks whether a given value is an array, returning true if it is, and false otherwise.
Array.indexOf() is a JavaScript method that returns the first index at which a specified element is found in an array, or -1 if the element is not present.
JSON.stringify()
converts a JavaScript object or value to a JSON string.
Object.create() is a JavaScript method that creates a new object with a specified prototype object and optional properties.
JavaScript 2015 (ES6) introduced major updates, including arrow functions, classes, modules, promises, and new syntax features like let, const, and template literals.
let
declares a block-scoped, reassignable variable in JavaScript.
Arrow functions are concise syntax for writing anonymous functions in JavaScript, using =>
.
Object destructuring is a syntax in JavaScript for extracting properties from an object into individual variables.
The for...of loop in JavaScript iterates over the values of an iterable object (like arrays, strings, or maps), allowing access to each element in the sequence.
The Symbol type in JavaScript is a primitive data type that creates unique, immutable identifiers often used as object property keys.
The findIndex()
method in JavaScript returns the index of the first element in an array that satisfies a provided testing function, or -1
if no element passes the test.
The Math.log10() method in JavaScript returns the base 10 logarithm of a given number.
JavaScript 2016 (ES7) introduced new features like the Array.prototype.includes() method and the exponentiation operator (**).
JavaScript 2017 (ES8) introduced features like async/await, Object.entries(), Object.values(), and the String.padStart() and String.padEnd() methods.
The Object.values() method in JavaScript returns an array of a given object's own enumerable property values.
JavaScript 2018 (ES9) introduced features like asynchronous iteration, rest/spread properties for objects, and improvements to regular expressions.
JavaScript threads refer to the execution contexts in which code runs, with the main thread handling most tasks and Web Workers enabling parallel execution of code in separate threads.
JavaScript 2019 (ES10) introduced features like the Array.prototype.flat(), flatMap(), Object.fromEntries(), and improvements to String and Array methods.
JavaScript 2020 (ES11) introduced features like the BigInt type, Nullish Coalescing Operator (??), Optional Chaining (?.), and dynamic import() syntax.
The Optional Chaining Operator (?.) allows you to safely access deeply nested properties of an object without throwing an error if a reference is null or undefined.
JavaScript 2021 (ES12) introduced new features like logical assignment operators, Promise.any()
, WeakRefs
, and improvements to the String.prototype.replaceAll()
method.
JavaScript 2022 (ES13) introduced new features and improvements, including the at()
method for arrays and Array.prototype.sort()
improvements, as well as additional methods for working with objects and strings.
The at()
method in JavaScript returns the element at a specified index in an array, supporting negative indexing.
The at()
method in JavaScript returns the character at a specified index in a string, supporting negative indexing.
JavaScript 2023 (ES2023) introduces new features and enhancements, including the Array.prototype.toSorted(), Array.prototype.toSpliced(), and improvements to regex, error handling, and promise methods for better performance and usability.
The JavaScript Array.with() method creates a new array with a specified element replaced at a given index, while leaving the original array unchanged.
JavaScript 2024 (ES2024) introduces new features and improvements to the language, continuing to enhance performance, syntax, and developer experience.
Object.groupBy() groups object properties based on string values returned by a callback, while Map.groupBy() does the same for Map entries, with both methods not modifying the original object.
In JavaScript, "IE" refers to Internet Explorer, a legacy web browser from Microsoft. "Edge" refers to Microsoft Edge, which replaced Internet Explorer as Microsoft's default browser.
Earlier announcements refer to information or statements shared previously, often in a public or official context.
Microsoft Edge Legacy is the original version of the Edge web browser, based on Microsoft's proprietary EdgeHTML engine, which was replaced by the Chromium-based Microsoft Edge in 2020.
The New Edge is a Chromium-based web browser developed by Microsoft, offering improved performance, security, and compatibility with modern web standards.
Old operating systems refer to outdated or legacy software platforms that no longer receive updates or support, such as Windows XP, Windows 95, or early versions of macOS.
JavaScript history traces its evolution from a simple scripting language created in 1995 by Brendan Eich for Netscape, to a powerful, widely-used language that powers modern web development with continuous updates through ECMAScript standards.
JS Objects
An object in JavaScript is a collection of key-value pairs, where each key (or property) is associated with a value, which can be any data type, including other objects or functions.
Object constructor functions are JavaScript functions used to create and initialize objects with specific properties and methods.
Object prototypes in JavaScript are templates for creating objects, allowing properties and methods to be shared across instances, enabling inheritance and code reuse.
Object methods in JavaScript are functions that are associated with an object and allow it to perform actions or manipulate its properties.
JavaScript's Object.entries()
method returns an array of a given object's own enumerable property key-value pairs.
JavaScript's Object.fromEntries()
creates an object from an array of key-value pair entries.
JavaScript's Object.groupBy()
groups an array of elements into an object based on a specified key or criterion.
Object properties in JavaScript are key-value pairs associated with an object, where each key (property name) is unique within the object and maps to a specific value.
JavaScript's Object.seal()
prevents adding or removing properties from an object while allowing modification of existing properties.
Adding a new property in JavaScript involves assigning a value to a new key on an object using dot or bracket notation.
Property attributes in JavaScript define the characteristics of an object's properties, such as writable
, enumerable
, and configurable
.
Object.getOwnPropertyNames() is a JavaScript method that returns an array of all enumerable and non-enumerable property names (including symbols) of a given object.
Object protection in JavaScript refers to techniques like freezing, sealing, or defining properties to prevent modifications to an object’s structure or behavior.
Object constructor functions are JavaScript functions used to create and initialize objects with specific properties and methods.
JS Funtions
Function definitions in JavaScript specify reusable blocks of code that can be executed when called, defined using the function keyword or arrow syntax (=>).
Function expressions in JavaScript define functions as part of an expression, allowing them to be assigned to variables or used inline.
The Function()
constructor in JavaScript creates new Function objects dynamically, allowing runtime definition of function code.
Function hoisting in JavaScript refers to the behavior where function declarations are moved to the top of their scope during compilation, allowing them to be called before they appear in the code.
In JavaScript, functions are first-class objects, meaning they can be assigned to variables, passed as arguments, or returned from other functions.
In JavaScript, functions are objects, meaning they can have properties and methods like other objects.
Arrow functions in JavaScript are a concise syntax for writing functions, using =>
and inheriting the this
value from the surrounding context.
Function parameters are variables listed in a function's definition, used to receive values (arguments) when the function is called.
Default parameters in JavaScript allow function parameters to have predefined values if no argument is provided for them.
The function rest parameter in JavaScript allows a function to accept an indefinite number of arguments as an array.
In JavaScript, arguments are passed by value, meaning that changes to parameters inside a function do not affect the original values.
Function invocation in JavaScript refers to calling a function to execute its code, typically by using its name followed by parentheses.
In JavaScript, this
refers to the context or object that a function is called on, determining the value of properties or methods within that function.
The global object is the default object in JavaScript that provides global variables, functions, and properties, such as window
in browsers or global
in Node.js.
Invoking a function as a method means calling it through an object, using the syntax object.method()
.
Invoking a function with a constructor creates a new object using the new
keyword, initializing it with the function as its blueprint.
The call() method in JavaScript allows a function to be invoked with a specified this value and arguments provided individually.
The apply() method in JavaScript is used to invoke a function with a specified this value and arguments provided as an array or array-like object.
The bind() method in JavaScript creates a new function that, when called, has its this value set to a specific object, with optional preset arguments.
A closure is a function that retains access to its lexical scope, even after the outer function has finished executing.
JavaScript nested functions are functions defined inside another function, which can access variables and parameters of the outer function.
A JavaScript closure is a function that remembers and can access variables from its outer scope, even after that scope has closed.
JS Classes
A class introduction is a brief overview that presents key information about the subject, structure, and objectives of a course or lesson.
Class inheritance allows one class to inherit properties and methods from another, enabling the creation of a new class based on an existing one.
A class static method or property is associated with the class itself, rather than with instances of the class.
JS Async
JavaScript callbacks are functions passed as arguments to other functions, to be executed after a certain task is completed.
Sequence control refers to the order in which statements or instructions are executed in a program.
JavaScript callbacks are functions passed as arguments to other functions, executed after a task is completed.
Use a callback when you need to perform an action after a function completes, such as handling asynchronous operations or events.
JavaScript asynchronous programming allows tasks to run in the background, enabling the execution of other code without waiting for the task to complete.
JavaScript Promises are objects that represent the eventual completion (or failure) of an asynchronous operation and its resulting value.
The Promise object has three properties: pending
, fulfilled
, and rejected
, representing the states of the promise.
JavaScript Promise examples illustrate how to handle asynchronous operations, such as waiting for a timeout or a file to load, using .then(), .catch(), and .finally() methods.
JavaScript async/await is a syntax that simplifies working with Promises, allowing asynchronous code to be written in a more synchronous and readable manner.
The await syntax is used to pause the execution of an async function until a Promise is resolved or rejected, simplifying asynchronous code.
JS HTML DOM
The Document Object Model (DOM) is a programming interface that allows scripts to dynamically interact with and manipulate the structure, style, and content of HTML or XML documents.
"What You Will Learn" outlines the key concepts or skills that will be covered in a tutorial or course.
DOM methods are functions provided by the Document Object Model that allow you to interact with and manipulate HTML or XML documents, such as accessing, modifying, or creating elements.
The DOM Document is an interface that represents the entire HTML or XML document, providing methods and properties to access and manipulate its structure, content, and elements.
DOM elements are individual components of an HTML or XML document, represented as objects in the DOM, that can be accessed and manipulated using properties and methods.
DOM - Changing HTML refers to the process of dynamically modifying the content, structure, or attributes of HTML elements in a document using JavaScript.
Changing the value of an attribute updates an element's property using JavaScript, typically with setAttribute()
or direct assignment.
Dynamic HTML content is web content that changes in response to user interactions or programmatic updates.
DOM Forms represent HTML <form> elements and provide methods and properties to access and manipulate form controls, such as input fields, buttons, and their values.
Automatic HTML form validation uses built-in browser features to check user input based on form attributes like required
, type
, and pattern
.
HTML Constraint Validation checks user input against rules defined by form attributes like required
, min
, and pattern
before submission.
DOM CSS refers to the ability to access and manipulate the style properties of HTML elements through JavaScript, allowing dynamic changes to the appearance of a document.
DOM Animation refers to using JavaScript to create and control animations by dynamically changing the properties of HTML elements over time within the Document Object Model.
DOM events are actions or occurrences that happen in the browser, such as user interactions (clicks, key presses) or changes in the document, which can trigger JavaScript functions to respond to those events.
HTML event attributes define actions to be executed when specific events, like clicks or input, occur on an element.
The onload
and onunload
events trigger actions when a page or element loads or unloads, often used for initialization or cleanup tasks.
The DOM EventListener is an interface that allows JavaScript to listen for and respond to specific events on HTML elements.
Adding an event handler to an element assigns a function to run when a specific event occurs, using methods like addEventListener()
.
Passing parameters involves providing values to a function so it can use them when executed.
DOM navigation refers to accessing and traversing the relationships between elements in an HTML document, such as parent, child, sibling, and other DOM node connections.
innerHTML is a property of an HTML element that gets or sets the HTML content (including text and markup) inside the element.
DOM nodes are individual objects that represent elements, attributes, text, or other parts of a web page's document structure in the Document Object Model (DOM).
DOM collections are groups of related DOM nodes (elements, attributes, or text) that can be accessed and manipulated as a list-like structure in JavaScript.
DOM NodeLists are collections of nodes (elements, text, attributes, etc.) returned by methods like querySelectorAll(), which can be iterated over but may not support all array methods.
The HTML DOM NodeList length
property returns the number of nodes in a NodeList.
JS Browser BOM
The JavaScript window object represents the browser window and provides access to the global context, including the document, location, history, and other browser-related features.
Window size refers to the dimensions of a browser window's viewport, accessible via window.innerWidth
and window.innerHeight
.
In JavaScript, screen is an object that provides information about the user's screen, such as its width, height, and color depth.
The location object in JavaScript provides information about the current URL and allows you to manipulate or redirect the browser to a different URL.
JavaScript history refers to the evolution of the programming language from its creation in 1995 by Brendan Eich to its current status as a versatile, widely-used language for web development.
The JavaScript Navigator object provides information about the user's browser and operating system, including details like the browser name, version, and platform.
A JavaScript popup alert is a message box that displays information to the user, typically used to alert or confirm an action.
A confirm box is a dialog that prompts the user to choose "OK" or "Cancel," returning true
or false
based on the selection.
A prompt box is a dialog that asks the user to enter input, returning the entered value or null
if canceled.
JavaScript timing refers to the ability to execute code after a specified delay or at repeated intervals using functions like setTimeout()
and setInterval()
.
To stop execution in JavaScript, use return
, break
, or throw
depending on the context (function, loop, or error).
The setInterval()
method repeatedly executes a function at specified intervals (in milliseconds).
JavaScript cookies are small pieces of data stored in the user's browser, used to remember information across sessions or track user behavior.
To read a cookie in JavaScript, use document.cookie
to access the cookie string and parse it for specific values.
The cookie string is a semicolon-separated list of key-value pairs representing cookies, accessible via document.cookie
.
A function to set a cookie assigns a name, value, and optional attributes (like expiration) to document.cookie
.
A function to check a cookie searches document.cookie
for a specific cookie name and returns its value if found.
JS Web APIs
Web APIs are interfaces that allow web applications to interact with external services, hardware, or other resources, enabling functionality like geolocation, media access, and data storage.
The Web Forms API allows developers to interact with and manipulate HTML forms, enabling tasks like form validation, data submission, and input handling.
The Web History API allows developers to manipulate the browser's history, enabling actions like navigating between pages, adding states, and handling back/forward actions without reloading the page.
The Web Storage API provides methods for storing and retrieving data in a web browser, allowing data to persist across page reloads, using localStorage and sessionStorage.
The Web Workers API allows JavaScript to run background tasks in separate threads, enabling concurrent execution without blocking the main thread.
The Web Fetch API provides a modern, promise-based method to make network requests and handle responses asynchronously in JavaScript.
The Web Geolocation API allows web applications to access the geographical location of a device, such as latitude and longitude.
JS AJAX
AJAX is a web development technique that allows asynchronous data exchange with a server, enabling dynamic updates to web pages without a full reload.
AJAX uses the XMLHttpRequest
object to send and receive data asynchronously between a web page and a server without reloading the page.
The onload
property defines a function to be executed when an XMLHttpRequest request completes successfully.
The onreadystatechange
property is an event handler that triggers when the readyState of an XMLHttpRequest
changes, typically used in AJAX requests.
An AJAX request is a method for asynchronously sending data to and receiving data from a web server without reloading the entire page.
AJAX - Server Response refers to the data sent back from the server after processing a client's request, which is then handled by JavaScript.
AJAX XML refers to using the XMLHttpRequest object to request and receive XML data asynchronously from a server.
AJAX PHP refers to using AJAX to send requests to a PHP script on the server, which processes the request and returns data to the client without reloading the page.
An AJAX ASP example demonstrates how to use AJAX to send requests to an ASP server script, which processes the request and returns data to the client without reloading the page.
AJAX Database refers to using AJAX to send requests to a server, which interacts with a database to retrieve or modify data and then returns the results to the client without reloading the page.
Applications are software programs designed to perform specific tasks or functions for the user, such as word processing, web browsing, or database management.
JS JSON
AJAX examples are demonstrations of how to use AJAX techniques to send requests and receive data asynchronously from a server without reloading the web page.
JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging data, often used in web applications.
JSON syntax is a set of rules for formatting data as key-value pairs, using objects, arrays, and basic data types such as strings, numbers, and booleans.
JSON (JavaScript Object Notation) is a lightweight, human-readable data format, whereas XML (eXtensible Markup Language) is a more complex, structured format used for data representation and storage.
JSON data types are String, Number, Object, Array, Boolean, and null.
JSON.parse
is a JavaScript method that converts a JSON string into a JavaScript object.
JSON.stringify
is a JavaScript method that converts a JavaScript object or value into a JSON string.
A JSON object is a collection of key-value pairs, where the keys are strings and the values can be strings, numbers, arrays, booleans, objects, or null
.
JSON arrays are ordered lists of values, which can be strings, numbers, objects, arrays, booleans, or null, enclosed in square brackets []
.
JSON Server is a full fake REST API that allows you to quickly generate a mock server using a simple JSON file.
JSON in PHP is a data format used for encoding and decoding data, allowing for easy transfer of data between a server and a client.
Client-side JavaScript is a scripting language that runs in the user's web browser to create interactive web pages and handle events.
PHP Database refers to the use of PHP to interact with databases, such as MySQL, to store, retrieve, and manipulate data.
"Use the data" refers to accessing, processing, or manipulating data for a specific purpose in a program or application.
JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write, and easy for machines to parse and generate, often used for transmitting data between a server and a web application.
JSONP (JSON with Padding) is a technique used to overcome cross-domain restrictions in web browsers by loading JSON data from a different domain through a script tag.
JS vs jQuery
jQuery DOM selectors are used to select and manipulate HTML elements in a web page using CSS-like syntax.
jQuery HTML refers to using jQuery to manipulate the HTML content, structure, and attributes of elements in a web page.
jQuery CSS refers to using jQuery to manipulate the CSS properties of HTML elements on a web page.
jQuery HTML DOM refers to using jQuery to navigate, manipulate, and interact with the elements of the HTML Document Object Model.
JS Graphics
Graphics refers to the visual representation of data, objects, or designs created using images, shapes, and colors in digital or physical formats.
JS Canvas is an HTML element that allows for dynamic, scriptable rendering of 2D shapes, images, and animations within a web page using JavaScript.
JS Plotly is a JavaScript library for creating interactive, visually rich charts and graphs, including 2D and 3D plots.
Bubble plots are scatter plots with markers that vary in size, color, and shape to represent additional dimensions of data.
Chart.js is a JavaScript library for creating interactive, customizable, and responsive charts on web pages.
Google Charts is a free JavaScript library for creating interactive and customizable charts for web applications.
D3.js is a JavaScript library for creating dynamic, interactive data visualizations using HTML, SVG, and CSS.