In JavaScript, errors are thrown by the engine, and exceptions are thrown by the developer. This means that all exceptions in JavaScript are objects while the majority of the exceptions are impleme...
According to professional coders, the functionalities of JavaScript should be kept separate from the content of HTML. First, is an example of the less desirable inline approach:
<input type=...
In addition to making things happen on a web page, you can use JavaScript to control the browser. To begin with, you can tell the browser to tell you its current location.
var where = window.loc...
In JavaScript, an object is an unordered collection of key-value. Each key-value pair is called a property.
The key of a property can be a string and the value of a property can be any value, e.g ...
The DOM is an acronym for Document Object Model. The DOM is an organization chart created automatically by the browser when your web page loads, for the whole web page. All the things in your web p...
Type conversion means transfer of data from one data type to another. Implicit conversion happens when the compiler or runtime automatically converts data type. The source code can also implicitly ...
In practice, we often need to create many objects of the same kind like users, goods, etc. In modern JavaScript, there is a more advanced class construct that introduces new great features which ar...
A typeOf operator accept an operand and returns a string representing the type of the operand. The following shows the syntax of the typeOf operator
typeOf(operator);
The operand can be a...
The Map object holds the key-value pair and remembers the original insertion order of the keys. A map remembers the original insertion order of the key. A map has a property that represents the siz...
The change in the state of an object is called an event. A good website is a responsive website. The user does something: click a button, move the mouse, presses a key and something happens. JavaSc...
An arrow function expression is a compact alternative to a traditional function expression, but is limited and cannot be used in all situations.
There are differences between arrow function and tr...
A function is a block of JavaScript that robotically does the same thing again and again, whenever you invoke its name. It saves you repetitive coding and makes your code easier to understand. On y...
Math is a built-in object that has properties and methods for mathematical constants and functions. It's not a function object.
Math works with the Number type. It doesn't work with BigInt.
Un...
Your web page includes a notice telling the user the current local date and time in his particular time zone. But what is the current date and time? Here is how JavaScript finds out.
var righ...
In JavaScript, number type is used to represent both integers and floating point values. The JavaScript number type uses IEEE-754 format.
ES2020 introduced a new primitive type bigInt that represe...
The string object is used to represent and manipulate a sequence of characters.
Strings are useful for holding data that can be represented in text form. Some of the most used operations on the st...
The array object, as with the arrays in other programming languages enables storing a collection of multiple items under a single variable name. The arrays are members for performing common array o...
The switch is a conditional statement like the if statement. The switch is useful when you want to execute one of the multiple code blocks based on the return value of a specified expression.
Synt...
The while statement creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement.
Syntax
w...
The for loop can execute a block of code several times.
Loops are handy, if you want to run the same code over and over again, each time with a different value.
You might have come across the son...