JavaScript createElement

dom in javascript

In this lesson we study JavaScript createElement method, useful to create new elements in the DOM. In the previous article we saw how to manipulate the DOM in JavaScript and studied methods for selecting elements on a page. You can consult the article at the following link: https://www.codingcreativo.it/en/javascript-dom/. JavaScript createElement – How to create elements … Leggi tutto

JavaScript DOM

dom javascript

In JavaScript it is possible to manipulate the DOM. In these lessons we will learn for example how to create new elements, add attributes or even delete elements in the HTML DOM. The web browser, when it loads the web page creates the DOM (Document Object Model). The DOM can be seen as a tree … Leggi tutto

callbacks in JavaScript

callbacks in JavaScript

In this lesson I propose some examples of the use of callbacks in JavaScript. I have already covered these callback functions in the following articles: JavaScript functions and return JavaScript Callback Callbacks Array method and callback functions callbacks in JavaScript – examples We create functions for calculating the area of ​​the rectangle and the area … Leggi tutto

JavaScript setTimeout

setTimeout JavaScript

JavaScript setTimeout is a method that allows you to call a function after a certain period of time, expressed in milliseconds. The syntax of this method is: setTimeout(function, milliseconds, p1, p2, …). Both milliseconds and p1 and p2 are optional parameters. The mandatory function will be executed after the time indicated in milliseconds has elapsed, … Leggi tutto

functions in JavaScript

funzioni javascript

In this lesson we will delve into the functions in JavaScript, already introduced in the previous lesson. The lesson can be consulted at the following link: introduction to functions. functions in JavaScript – examples In particular, in this example I propose a demonstration of how it is possible to use multiple returns. So let’s create … Leggi tutto

callback functions

Function callback

The callback functions are used in JavaScript to ensure that the code is asynchronous, i.e. executed after a certain event, such as when a button is clicked, or when you pass over an element of the html page, etc. We have also seen in previous articles that callback functions can be passed as arguments to … Leggi tutto

callbacks

callbacks

Callbacks in JavaScript, as seen in the previous lesson, can be passed as arguments to other functions. In fact, functions in JavaScript are objects. We can also see this simply by doing the console.log of a function. For example, if we have this JavaScript function: var number = function(item) { return 10; }; console.log(number); If … Leggi tutto

JavaScript callback

JavaScript callback

In this lesson we will talk about JavaScript callback functions, which are functions that are passed as parameters to other functions. In the JavaScript version ES5 they are widely used, while in the ES6 they leave room for the promises that have become a native component of the language. A few years ago, in fact, … Leggi tutto

format JSON

JSON

format JSON – JSON is a format used for data exchange and is the acronym for JavaScript Object Notation. It is based on the JavaScript language and is used a lot for asynchronous programming, therefore with ajax, as we will see in the next lessons. JSON is a text format, so it is a string. … Leggi tutto

prompt JavaScript

prompt JavaScript

In this article we will talk about prompt in JavaScript, that is, windows that require a user to enter data. The prompt () method therefore allows you to bring up windows to interact with the user. prompt JavaScript – example 1 We want to make this example: when we click on the enter name button, … Leggi tutto

confirm JavaScript

javascript confirm

In this article we will talk about confirm in JavaScript, that is, how to create a window where the user can make a choice. With the confirm () method, unlike the alert () method, communication is therefore not unilateral but bilateral. confirm JavaScript – example 1 Let’s immediately take an example of use. Try to … Leggi tutto

alert JavaScript

javascript alert

In this lesson we will talk about alert in JavaScript, i.e. window.alert(), used to communicate a message to the user. Alert () is therefore a method of the window object, which serves to show an alert window. The window object is therefore the main JavaScript object and represents the entire browser window. This object also … Leggi tutto

JavaScript functions

funzioni in javascript

JavaScript functions are fundamental blocks of code, consisting of one or more instructions, which perform one or more actions. A function in JavaScript is defined by the keyword function followed by the name of the function and by the arguments, however optional, enclosed in round brackets and separated by commas. The instructions are then placed … Leggi tutto

JavaScript for loop

JavaScript for

In this lesson we will talk about JavaScript for loop and we do some usage examples to better understand how it works. The for loop is an iterative structure that serves to repeat statements a certain number of times. JavaScript for loop – syntax The syntax of the for loop is as follows: for(expression1; expression2; … Leggi tutto

JavaScript do while

do while javascript

In JavaScript the do while loop, as well as in other languages ​​where this construct exists, allows you to execute instructions at least once. If the condition is true then the cycle is repeated again, otherwise it goes to the next instruction. The do-while loop is in fact a post-conditional construct. JavaScript do while – … Leggi tutto

JavaScript while loop

While JavaScript

In this lesson we will talk about the JavaScript while loop and we will also do some very simple examples to understand how it works. The while is a pre-conditional construct, that is, the condition check occurs before the execution of the instructions indicated in curly brackets. The syntax of the while loop is as … Leggi tutto

length of string JavaScript

Proprietà length di JavaScript

The length of a string in JavaScript is calculated with the length property, that count the amount of characters in that string. The syntax is therefore the following: string.length, where string represents the string whose length is to be calculated. length of string JavaScript – example In this first example we will get the number … Leggi tutto

JavaScript charCodeAt

charCodeAt JavaScript

JavaScript charCodeAt method, to be used on strings, takes an index as an optional parameter. This method returns the Unicode character of the corresponding character specified by the index. So the syntax is as follows: string.charCodeAt(index). If the index is not specified, it will have a default value of 0. Recall that Unicode is an … Leggi tutto