If you are not sure if the website you would like to visit is secure, you can verify it here. Enter the website address of the page and see parts of its content and the thumbnail images on this site. None (if any) dangerous scripts on the referenced page will be executed. Additionally, if the selected site contains subpages, you can verify it (review) in batches containing 5 pages.
favicon.ico: javascript-tutorial.com/operators/optional-chaining-operator - Optional chaining operator - T.

site address: javascript-tutorial.com/operators/optional-chaining-operator redirected to: javascript-tutorial.com/operators/optional-chaining-operator

site title: Optional chaining operator - The complete JavaScript Tutorial

Our opinion (on Thursday 19 November 2026 15:34:31 UTC):

GREEN status (no comments) - no comments
After content analysis of this website we propose the following hashtags:


page from cache: 6 hours ago
Meta tags:

Headings (most frequently used words):

for, the, javascript, web, optional, chaining, operator, objects, using, 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, parts, methods,

Text of the page (most frequently used words):
the (51), user (25), #operator (22), you (19), name (18), javascript (17), error (17), object (17), and (16), this (15), access (13), alert (13), firstname (13), for (13), introduction (12), defined (12), operators (12), chaining (11), undefined (11), been (10), optional (10), try (10), properties (10), with (9), will (9), property (9), that (9), objects (8), methods (8), let (8), which (8), not (7), can (7), example (7), errors (6), but (6), hasn (6), article (5), has (5), nested (5), have (5), lastname (5), your (4), execution (4), getname (4), would (4), conditional (4), first (4), what (4), functions (4), tutorial (3), following (3), nullish (3), coalescing (3), when (3), working (3), especially (3), complex (3), from (3), external (3), very (3), any (3), also (3), method (3), return (3), like (3), don (3), use (3), uncaught (3), function (3), thrown (3), parts (3), multiple (3), quite (3), john (3), doe (3), where (3), using (3), won (3), forgiving (3), now (3), obviously (3), web (3), regular (3), expressions (3), catching (3), into (2), languages (2), language (2), here (2), useful (2), allow (2), without (2), causing (2), code (2), summary (2), works (2), expect (2), want (2), because (2), well (2), typeerror (2), chain (2), result (2), need (2), throw (2), notice (2), line (2), being (2), finally (2), receive (2), source (2), may (2), does (2), however (2), were (2), these (2), json (2), bit (2), see (2), script (2), doesn (2), exist (2), called (2), throwing (2), asp (2), net (2), dom (2), window (2), bom (2), search (2), types (2), catch (2), fields (2), inheritance (2), getters (2), setters (2), prototypes (2), values (2), parameters (2), ternary (2), remainder (2), logical (2), modify (2), assign (2), increment (2), decrement (2), arithmetic (2), comparison (2), assignment (2), array (2), basics (2), loops (2), statement (2), toc (2), localization, suggest, correction, contact, com, 2007, 2026, fully, translated, preferred, list, help, translate, click, czech, next, previous, they, come, sources, prevent, unexpected, stops, behavior, trying, call, otherwise, stopped, firstchar, secondchar, many, needed, place, basically, telling, hey, sure, case, willing, accept, subtle, difference, found, last, added, question, mark, after, context, act, mind, arrived, purpose, sometimes, various, reason, often, how, cause, second, one, cannot, read, reading, means, parent, saw, work, just, fine, only, consisting, two, becomes, less, clear, more, those, later, consider, extended, our, halted, situation, shouldn, happen, lot, clearly, should, corrected, referenceerror, leave, out, above, create, new, then, instead, halt, simply, say, unlike, some, other, programming, member, instance, show, pretty, cool, understand, why, give, little, background, information, wpf, php5, jquery, html5, css3, webforms, mvc, location, history, tag, general, replace, capturing, groups, match, regex, flags, options, handling, static, classes, extension, accessors, recursive, callback, anonymous, default, math, date, string, number, built, type, conversion, null, strings, numbers, booleans, data, while, switch, control, structures, truthy, falsy, variables, basic, syntax, hello, world, tools, getting, started, libraries, webbrowser, about, chapter, table, contents, complete,


Text of the page (random words):
optional chaining operator the complete javascript tutorial javascript tutorial toc table of contents chapter article toc 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 using the optional chaining operator for multiple parts for methods 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 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 operators optional chaining operator in this article i ll show you a pretty cool operator called the optional chaining operator but to understand why it s so useful allow me to give you a little bit of background information first unlike some other programming languages javascript is quite forgiving if you try to access a member of an object which hasn t been defined for instance the following example won t result in any errors let user alert user name as you can see i create a new user object with no properties and then i try to access a property called name obviously this property doesn t exist but instead of throwing an error and or causing the execution to halt javascript will simply return undefined which is also what the alert will say however javascript won t be quite as forgiving if you try to access an object that hasn t been defined so if we were to leave out the first line of the example above and try to access the user object which now obviously doesn t exist an error will be thrown error uncaught referenceerror user is not defined alert user as you can see an error is thrown and the execution of the script is halted now obviously this situation where you try to access an object that hasn t been defined shouldn t happen a lot and if it does it s clearly an error that should be corrected it becomes less clear what has been defined and what hasn t been defined when working with complex nested objects especially if you receive these from an external source e g as json objects more on those later so consider the following example where we have extended our user object a bit let user name firstname john lastname doe alert user name firstname this example will work just fine we only access properties which have been defined the name property of the user object is now an object as well consisting of two properties firstname and lastname however this also means that if we were to try and access these nested properties firstname lastname without the parent object name being defined javascript would not be as forgiving as we saw in the first example let user name firstname john lastname doe undefined no error alert user name error uncaught typeerror cannot read properties of undefined reading firstname alert user name firstname notice how the first alert won t cause an error but the second one does we can access a property that has not been defined name but we can t access a property firstname of an object that hasn t been defined name using the optional chaining operator with that in mind we have finally arrived at the purpose of this article because sometimes you don t want your code to throw errors if you try to access various nested properties the reason will often be that you re working with complex objects which you receive from an external source which may or may not have the properties you would expect this is where we can use the optional chaining operator let user name firstname john lastname doe undefined no error alert user name undefined no error alert user name firstname notice the very subtle difference in this example to be found on the very last line i have added a question mark after the name property which in this context will act as a conditional chaining operator the chain being the nested properties with this operator in place i m basically telling javascript hey i would like to access the firstname property on the name object but i m not quite sure that the name object has been defined so in case it hasn t i m willing to accept undefined as a result you don t need to throw any errors for multiple parts and you can use it for as many parts of the chain as needed like this let user undefined no error alert user name firstname firstchar secondchar for methods when trying to call a method on an object the method has to be defined otherwise an error will be thrown and execution will be stopped let user error uncaught typeerror user getname is not a function alert user getname but if we don t want this behavior we can use the optional chaining operator because it works for methods as well here s an example let user undefined no error alert user getname it also works if you expect this method to return an object on which you would like to access a property let user undefined no error alert user getname firstname summary when working with objects especially complex nested objects and especially if they come from external sources the optional chaining operator is very useful to prevent unexpected errors it will allow you to try to access undefined objects properties methods without causing any execution stops in your code nullish coalescing operator 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 suggest correction localization
Images from subpage: "javascript-tutorial.com/built-in-objects/json/" Verify
Images from subpage: "javascript-tutorial.com/functions/introduction/" Verify
Images from subpage: "javascript-tutorial.com/functions/function-parameters/... " Verify
Images from subpage: "javascript-tutorial.com/functions/function-parameters-with-d... " Verify
Images from subpage: "javascript-tutorial.com/functions/anonymous-functions/... " Verify

Verified site has: 72 subpage(s). Do you want to verify them? Verify pages:

1-5 6-10 11-15 16-20 21-25 26-30 31-35 36-40 41-45 46-50
51-55 56-60 61-65 66-70 71-72


Top 50 hastags from of all verified websites.

Supplementary Information (add-on for SEO geeks)*- See more on header.verify-www.com

Header

HTTP/2 301
cache-control private
content-type text/html; charset=utf-8
location /operators/optional-chaining-operator/
server Microsoft-IIS/10.0
set-cookie ASP.NET_SessionId=5pzlknsxu1p3qnkcarlwn1tz; path=/; HttpOnly; SameSite=Lax
x-aspnetmvc-version 5.2
x-aspnet-version 4.0.30319
x-powered-by ASP.NET
date Thu, 19 Nov 2026 08:42:21 GMT
content-length 155
HTTP/2 200
cache-control private
content-type text/html; charset=utf-8
server Microsoft-IIS/10.0
set-cookie ASP.NET_SessionId=fgsssoc5hcsvdphj3em04jtr; path=/; HttpOnly; SameSite=Lax
x-aspnetmvc-version 5.2
x-aspnet-version 4.0.30319
x-powered-by ASP.NET
date Thu, 19 Nov 2026 08:42:21 GMT
content-length 25771

Meta Tags

title="Optional chaining operator - The complete JavaScript Tutorial"
name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"

Load Info

page size25771
load time (s)0.172149
redirect count1
speed download149831
server IP 142.132.248.53
* all occurrences of the string "http://" have been changed to "htt???/"