Meta tags:
Headings (most frequently used words):
javascript, objects, the, for, web, multiple, return, values, metadata, arrays, summary, chapter, article, toc, about, getting, started, basics, control, structures, data, types, built, in, operators, functions, classes, error, handling, regular, expressions, general, bom, dom,
Text of the page (most frequently used words):
the (55), #return (23), javascript (17), #function (16), and (14), fullname (13), introduction (12), values (12), functions (11), let (11), for (11), name (10), this (9), array (9), that (9), you (9), article (8), multiple (8), getnameparts (8), can (8), with (8), nameparts (8), but (7), john (7), please (7), objects (6), doe (6), just (6), translation (6), operators (6), more (5), are (5), object (5), keyword (5), then (5), metadata (5), operator (5), tutorial (4), into (4), languages (4), not (4), help (4), here (4), returning (4), arrays (4), first (4), split (4), firstname (4), lastname (4), will (4), use (4), already (4), have (4), methods (4), parameters (4), translated (3), language (3), click (3), recursive (3), from (3), last (3), since (3), alert (3), look (3), get (3), when (3), one (3), there (3), programming (3), which (3), well (3), value (3), only (3), try (3), started (3), dutch (3), web (3), regular (3), expressions (3), catching (3), has (2), following (2), your (2), translate (2), natively (2), same (2), simply (2), summary (2), properties (2), instead (2), result (2), easy (2), create (2), think (2), make (2), above (2), example (2), back (2), how (2), because (2), other (2), possible (2), course (2), means (2), reached (2), returned (2), work (2), point (2), working (2), using (2), optional (2), original (2), info (2), item (2), vote (2), translating (2), chapter (2), button (2), about (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), callback (2), anonymous (2), default (2), basics (2), loops (2), statement (2), toc (2), localization, contact, com, 2007, 2026, been, fully, preferred, list, czech, next, previous, doesn, support, quite, simple, achieve, functionality, mostly, doing, consumer, bit, cleaner, obtain, named, indexes, elegant, solution, might, fly, really, personally, code, easier, read, nicer, written, version, where, method, once, matter, accessing, two, individual, case, display, format, way, our, could, wrote, several, out, supports, works, related, directly, workaround, also, acts, exit, command, soon, exited, caller, situation, second, never, won, returns, some, likely, urge, define, than, even, consider, takes, full, like, splits, both, discussed, fact, many, though, fine, without, ever, anything, looking, english, logged, page, reloading, login, satisfied, specific, may, down, reaches, certain, negative, threshold, removed, submit, altered, good, reasons, they, see, looks, wrong, consult, sure, know, fluent, any, highlighted, left, border, remember, images, should, their, titles, inside, current, status, yellow, untranslated, element, community, seems, process, yet, 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, chaining, nullish, coalescing, ternary, remainder, logical, modify, assign, increment, decrement, arithmetic, comparison, assignment, json, math, date, string, number, built, type, conversion, null, undefined, tekenreeksen, numbers, booleans, data, while, switch, control, structures, truthy, falsy, variables, basic, syntax, hello, world, tools, need, getting, libraries, webbrowser, what, table, contents, complete,
Text of the page (random words):
multiple return values the complete javascript tutorial javascript tutorial toc table of contents chapter article toc introduction function parameters function parameters with default values anonymous functions callback functions recursive functions multiple return values arrays objects summary 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 tekenreeksen 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 the community is working on translating this tutorial into dutch but it seems that no one has started the translation process for this article yet if you can help us then please click more info if you are fluent in dutch then please help us just point to any untranslated element highlighted with a yellow left border remember that images should have their titles translated as well inside the article and click the translation button to get started or have a look at the current translation status for the dutch language if you see a translation that you think looks wrong then please consult the original article to make sure and then use the vote button to let us know about it metadata please help us by translating the following metadata for the article chapter if they are not already translated if you are not satisfied with the translation of a specific metadata item you may vote it down when it reaches a certain negative threshold it will be removed please only submit an altered translation of a metadata item if you have good reasons to do so please login to translate metadata already logged in please try reloading the page more info looking for the original article in english functions multiple return values we already discussed the fact that functions in javascript as well as in many other programming languages can return a value by using the return keyword it is optional though a function can work just fine without ever returning anything at some point when working with functions you will likely get the urge to define a function that can return more than one value but is that even possible in javascript as an example consider this function which takes a full name like john doe and then splits it up into a first and a last name can we return both values function getnameparts fullname let nameparts fullname split return nameparts 0 return nameparts 1 let fullname john doe only returns john alert getnameparts fullname no of course this won t work because the return keyword also acts as an exit command for the function which means that as soon as the return keyword is reached the function is exited and the value returned to the caller in this situation it just means that only the first name will be returned and the second return keyword is never reached there are several programming languages out there which natively supports multiple return values but because of how the return keyword works in javascript as well as in other related programming languages it s not possible to directly return multiple values but there is of course a workaround arrays one way of returning multiple values is to simply return an array here s how our function from above could look if we re wrote it to return an array function getnameparts fullname let nameparts fullname split return nameparts let fullname john doe let firstname getnameparts fullname 0 let lastname getnameparts fullname 1 doe john alert lastname firstname since we already get an array back when we use the array split method we can just return it once we have an array back from the function it s just a matter of accessing the two individual values in this case we use it to display the name in the last name first name format objects arrays are easy to return but a more elegant solution might be to create an object and return it since we can just create objects on the fly in javascript this is really easy to do and i personally think that it will make the code easier to read and nicer to look at here s a re written version of the above example where we use an object instead of an array function getnameparts fullname let nameparts fullname split let result firstname nameparts 0 lastname nameparts 1 return result let fullname john doe let name getnameparts fullname doe john alert name lastname name firstname we re mostly doing the same here but as the consumer of the getnameparts function it s a bit more cleaner to obtain the first and last name since we can do it with named properties instead of indexes in the array summary javascript doesn t natively support returning multiple values from a function but it s quite simple to achieve the same functionality by simply returning arrays or objects recursive functions previous introduction next this article has been fully translated into the following languages czech 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 localization
|