Set of JavaScript basic syntax to add, execute and write basic programming paradigms in Javascript
Adding internal JavaScript to HTML
Adding external JavaScript to HTML
JavaScript Function syntax
Changing content of a DOM Element
This will print the value of a in JavaScript console
Conditional statements are used to perform operations based on some conditions.
The block of code to be executed, when the condition specified is true.
If the condition for the if block is false, then the else block will be executed.
A basic if-else ladder
Switch case statement in JavaScript
Iterative statements facilitate a programmer to execute any block of code lines repeatedly and can be controlled as per conditions added by the programmer.
For loop syntax in JavaScript:
Example:
Use for...in when you need to iterate through the keys of an object and access their values.
or you can use it for Arrays also. But its better to use FOR OF loop for Array
Use for...of when you need to iterate through the values of an iterable object in order.
Runs the code until the specified condition is true.
Example
A do while loop is executed at least once despite the condition being true or false.
Example
The string is a sequence of characters that is used for storing and managing text data.
Returns the character from the specified index.
Joins two or more strings together.
Returns the index of the first occurrence of the specified character from the string else -1 if not found.
Searches a string for a match against a regular expression.
Searches a string for a match against a specified string or char and returns a new string by replacing the specified values.
Searches a string against a specified value.
Splits a string into an array consisting of substrings.
Returns a substring of a string containing characters from the specified indices.
The array is a collection of data items of the same type. In simple terms, it is a variable that contains multiple values.
Containers for storing data.
Joins two or more arrays together.
Returns the index of the specified item from the array.
Converts the array elements to a string.
Deletes the last element of the array.
This method reverses the order of the array elements.
Sorts the array elements in a specified manner.
Converts the array elements to a string.
Returns the relevant Number Object holding the value of the argument passed.
Rounds a number upwards to the nearest integer and returns the result.
Returns the value of E^x.
Returns the logarithmic value of x.
Returns the value of x to the power y.
Returns a random number between 0 and 1.
Returns the square root of a number x.
Date object is used to get the year, month, and day. It has methods to get and set day, month, year, hour, minute, and seconds.
Returns the date from the date object.
Returns the day from the date object.
Returns the hours from the date object.
Returns the minutes from the date object.
Returns the seconds from the date object.
Returns the time from the date object.
Any change in the state of an object is referred to as an Event. With the help of JS, you can handle events, i.e., how any specific HTML tag will work when the user does something.
Fired when an element is clicked.
Fired when an element is right-clicked.
Fired when an element is double-clicked.
Fired when an element is entered by the mouse arrow.
Fired when an element is exited by the mouse arrow.
Fired when the mouse is moved inside the element.
Keyboard events are fired when a user interacts with the keyboard. You can use JavaScript to handle these events, such as detecting when a key is pressed, when a key is released, or when a key is held down.
Fired when the user is pressing a key on the keyboard.
Fired when the user presses a key on the keyboard.
Fired when the user releases a key on the keyboard.
Errors are thrown by the compiler or interpreter whenever they find any fault in the code, and it can be of any type like syntax error, run-time error, logical error, etc. JavaScript provides some functions to handle the errors.
Try the code block and execute catch when an error is thrown.
Methods that are available from the window object.
Used to alert something on the screen.
The blur() method removes focus from the current window.
Keeps executing code at a certain interval.
Executes the code after a certain interval of time.
The Window. close() method closes the current window.
The window.confirm() instructs the browser to display a dialog with an optional message and to wait until the user either confirms or cancels.
Opens a new window.
Prompts the user with a text and takes a value. The second parameter is the default value.
window.scrollBy(100, 0); // Scroll 100px to the right
Scrolls the document to the specified coordinates.
Clears the setInterval. The variable is the value returned by setInterval call.
Clears the setTimeout. The variable is the value returned by setTimeout call.
Stops further resource loading.
The browser creates a DOM (Document Object Model) whenever a web page is loaded, and with the help of HTML DOM, one can access and modify all the elements of the HTML document.
Selector to select the first matching element.
A selector to select all matching elements.
Select elements by tag name.
Select elements by class name.
Select an element by its id.
Create new elements in the DOM.
Create a new element.
Create a new text node.