Cela montre sans JavaScript tutorial vous une base JavaScript trucs et astuces pour d
- Demo
- Agrandir
- Recharger
- New window
G�n�rez vos vid�os d'entreprise par l'IA avec la voix ou simplement du texte
Votre premi�re application vid�o AI GRATUITE ! Automatisez votre premi�re vid�o AI. Cr�ez votre vid�o professionnelle en 5 minutes gr�ce � l'IA. Aucun �quipement ni comp�tence en montage vid�o requis. Production vid�o sans effort pour les sp�cialistes du marketing de contenu.
Javascript Looping
The For Loop
You use looping to perform an action over and over again. One of the ways you can loop, is to use what is called a for loop. A for loop continues performing actions until a condition is met. This is the basic structure of a for loop:
for (initial expression; condition to be met; edit the value of expression)
{
... javascript code...
}
An example of a real for loop looks like this:
for (var i = 1; i < 100; i++)
{
document.writelin(i);
}
The above code performs the following actions:
- Create a variable i and assign it an initial value of 1
- Define that the code below will be performed over and over until i is no longer less than 100
- i++, is shorthand for add 1 to i. This action will be preformed after the code below is run through. So, the first number printed will be the number 1.
- The code document.writelin(i); prints the value of i on the browser screen. document.writeln, is a prebuilt function for writing to the browser screen and it is ended with a semicolon (;)
- The curly braces are used to define the code that needs to be performed over and over again.
The While Loop
A while loop can also be used for looping. It's basic structure is:
while (condition)
{
... code...
iterator
}
An example of a real while loop:
while ( i < 100)
{
document.writelin(i);
i++;
}
It performs the same action as the previous for loop.
The Do-While Loop
The Do-While loop is almost identical to the while loop except it doesn't check if the condition has been met before executing the code in curly braces first. It's basic structure is:
do {
... code...
}
while ( i < 100 )
An example of a real do-while loop:
var i = 1;
do{
document.writelin(i);
i++;
}
while( i < 100 )
This code performs the same exact actions as the previous for and while loop.
The For-In Loop
The final looping tool may be a little confusing. Everything in Javascript is considered an object. Objects have variables and functions that they can perform. Programming languages used to be called procedural languages because they mainly performed an action and then another over and over again. Then a new form of programming was invented called object oriented programming. Through OOP, you instead create a bunch of objects that interact with each other. I'll dive more into this subject later, but I thought I should explain OOP before I dive into the next loop.
You use the for-in loop for looping through all of the variables of an object. If you have variables assigned to an object you created, this loop cycles through them. Here is the basic structure of a for-in loop:
for (var objectVariable in objectItself)
{
... code...
}
Here is a real example:
for (var objectVariable in objectItself)
{
infoOnObject = objectName + "." + objectVariable + " = " + objectItself[objectVariable];
document.writelin(infoOnObject);
}
If the previous code is confusing, skip it and we'll come back to it later. Otherwise, this is what it is doing:
- The for-in loop, loops through all of the variables of the object, which is named "objectItself"
- Each time it finds a new variable it assigns that variable to the variable objectVariable
- Then the name of the objects variable and the value of that variable are combined and stored in the variable infoOnObject
- Then the function document.writelin prints out the variable name and variable value, to the browser screen. Ex. "variable1 = 23″
We'll talk a lot more about objects later. Don't worry if you didn't totally grasp this one concept.
- Sent (0)
- Nouveau
Générez vos vidéos d'entreprise par l'IA avec la voix ou simplement du texte
chatGPTaz.com
Parlez à ChatGPT dans votre langue maternelle
AppAIVidéo
Votre première application vidéo AI GRATUITE
Deepfake Video
Deepfake AI Video Maker
Deepfake
Deepfake AI Video Maker
AI Deep Fake
Deepfake AI Video Maker
AIvidio
AI Video Mobile Solutions
AIvideos
AI Video Platform & Solutions
AIvedio
AI Video App Maker
Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)
Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)
Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT
Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT
Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT
Powerful AI Presentation PPT Maker for FREE
Build an impressive presentation with our free online AI presentation app
Your next top AI Assistant
Claude AI, developed by Anthropic
Your next top AI Assistant
Claude AI, developed by Anthropic
Temu gratuit 500 $ pour les nouveaux utilisateurs
Claim Free Temu $500 Credit via Affiliate & Influencer Program
Crédits publicitaires TikTok gratuits
Maîtrisez les publicités TikTok pour le marketing de votre entreprise
Dall-E-OpenAI.com
Générez automatiquement des images créatives avec l'IA
chatGPT4.win
Parlez à ChatGPT dans votre langue maternelle
Premier produit d'intelligence artificielle d'Elon Musk - Grok/UN.com
Parlez au chatbot Grok AI dans votre langue
Outily.win
Centre d'outils ouvert et gratuit, utilisable par tous et pour tous, avec des centaines d'outils
GateIO.gomymobi.com
Airdrops gratuits à réclamer et à partager jusqu'à 150 000 $ par projet
iPhoneKer.com
Économisez jusqu'à 630 $ à l'achat d'un nouvel iPhone 16
Acheter le robot Tesla Optimus
Commandez votre robot Tesla Bot : Optimus Gen 2 dès aujourd'hui pour moins de 20 000 $