Meta tags:
Headings (most frequently used words):
the, if, javascript, for, web, else, objects, statement, summary, chapter, article, toc, about, getting, started, basics, control, structures, data, types, built, in, operators, functions, classes, error, handling, regular, expressions, general, bom, dom, multiple, conditions,
Text of the page (most frequently used words):
the (45), you (18), true (18), #statement (15), for (15), alert (13), javascript (12), else (12), and (11), age (10), introduction (10), not (8), operators (8), answer (8), can (7), conditions (7), var (7), your (6), more (6), code (6), with (6), this (5), that (5), need (5), confirm (5), knew (5), something (5), condition (5), operator (5), tutorial (4), use (4), control (4), was (4), have (4), multiple (4), line (4), methods (4), functions (4), loops (4), article (3), into (3), here (3), next (3), switch (3), just (3), should (3), but (3), structures (3), what (3), well (3), guess (3), one (3), works (3), example (3), whether (3), try (3), web (3), object (3), regular (3), expressions (3), catching (3), language (2), previous (2), truthy (2), falsy (2), world (2), programming (2), how (2), statements (2), chapter (2), some (2), advanced (2), summary (2), want (2), prompt (2), using (2), then (2), surround (2), block (2), only (2), does (2), drivers (2), license (2), will (2), drive (2), car (2), hasdriverslicense (2), simply (2), allows (2), specify (2), about (2), simple (2), most (2), basic (2), asp (2), net (2), dom (2), window (2), bom (2), search (2), error (2), types (2), conditional (2), errors (2), catch (2), fields (2), inheritance (2), getters (2), setters (2), prototypes (2), objects (2), values (2), function (2), parameters (2), array (2), basics (2), while (2), toc (2), localization, suggest, correction, contact, com, 2007, 2026, has, been, fully, translated, following, languages, preferred, list, help, translate, click, italian, dutch, czech, easy, understand, yet, powerful, new, might, surprised, when, realize, common, they, are, also, know, there, alternative, shorter, notation, doing, discuss, now, let, move, course, blocks, around, like, saw, examples, infant, child, teenager, adult, nested, create, pretty, logic, false, again, lines, both, our, current, may, case, its, which, obviously, together, appropriate, between, allow, very, realistic, hopefully, job, illustrating, allowed, checking, supplied, considered, many, those, later, add, too, remember, talked, previously, contain, than, curly, brackets, creating, first, run, changing, take, input, from, user, really, test, controlling, flow, important, concepts, structure, probably, executed, wpf, php5, jquery, html5, css3, webforms, mvc, location, history, script, tag, general, replace, capturing, groups, match, regex, flags, options, throwing, finally, handling, static, classes, extension, property, accessors, properties, return, recursive, callback, anonymous, default, optional, chaining, nullish, coalescing, ternary, remainder, logical, modify, assign, increment, decrement, arithmetic, comparison, assignment, json, math, date, string, number, built, type, conversion, null, undefined, strings, numbers, booleans, data, variables, syntax, hello, tools, getting, started, libraries, webbrowser, table, contents, complete,
Text of the page (random words):
the if statement the complete javascript tutorial javascript tutorial toc table of contents chapter article toc the if statement multiple conditions if else if else if summary the switch statement loops for and while loops for of and for in about javascript what is javascript javascript and the webbrowser javascript libraries getting started the tools you need hello world the basics basic javascript syntax variables truthy falsy control structures the if statement the switch statement loops for and while loops for of and for in data types introduction booleans numbers strings null undefined type conversion built in objects introduction number string array the basics array methods date math json operators introduction the assignment operator comparison operators arithmetic operators increment decrement operators modify and assign operators logical operators remainder operator conditional ternary operator nullish coalescing operator optional chaining operator functions introduction function parameters function parameters with default values anonymous functions callback functions recursive functions multiple return values objects introduction properties methods property accessors getters setters prototypes prototypes inheritance extension classes introduction fields methods getters setters inheritance static fields methods error handling introduction catching errors try catch catching throwing errors try catch finally error types conditional catching regular expressions introduction regex flags options search match with regular expressions using capturing groups search replace with regular expressions javascript for web general introduction window dom bom the script tag javascript for web the bom the window object the history object the location object javascript for web the dom introduction javascript asp net mvc asp net webforms c css3 html5 jquery php5 wpf control structures the if statement controlling the flow of your code is one the most important concepts of programming and the most basic control structure is probably the if statement it simply allows you to specify a condition for whether or not the next line s should be executed here s a simple example if something true alert something is true the first line is the if statement a simple condition for whether or not the next line should run we can try changing it into something that will take input from the user to really test if it works or not var answer confirm is it true if answer true alert i knew it was true remember as we talked about previously in this tutorial if you need the condition to contain more than one line you have to surround it with curly brackets creating a block of code var answer confirm is it true if answer true alert i knew it was true alert i knew it too multiple conditions the if statement works simply by checking whether the supplied condition can be considered true this allows you to specify as many conditions as you want to we can use the and as well as the or operators more on those later to add conditions var age prompt what s your age var hasdriverslicense confirm do you have a drivers license if hasdriverslicense age 18 age 80 alert i guess you can be allowed to drive a car so if you have a drivers license or an appropriate age between 18 and 80 this code will allow you to drive a car that s not a very realistic example but hopefully it does the job of illustrating how you can use multiple conditions in your if statement if else our current if statement only does something if the condition is true but we may need to do something else in case its not true for that we have the else statement which obviously only works together with the if statement here s an example var answer confirm is it true if answer true alert i knew it was true else alert oh well guess not then and again if you need more lines of code for one or both of the conditions just surround it with a block var answer confirm is it true if answer true alert i knew it was true more true code else alert oh well guess not then more false code if else if using nested if statements we can create some pretty advanced logic var age prompt what s your age if age 1 alert infant else if age 13 alert child else if age 18 alert teenager else alert adult if you want or need to you can of course use blocks around the conditions just like we saw in previous examples summary the if statement is easy to use and understand yet so powerful if you re new to the world of programming you might be surprised when you realize just how common they are you should also know that there s an alternative shorter notation for doing if else statements but we ll discuss that in the chapter on operators for now let s move on to some of the more advanced control structures truthy falsy previous the switch statement next this article has been fully translated into the following languages czech dutch italian is your preferred language not on the list click here to help us translate this article into your language javascript tutorial com 2007 2026 contact us suggest correction localization
|