Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Output not defined Date: Fri, 01 Jun 2018 17:54:01 +0100 Organization: A noiseless patient Spider Lines: 15 Message-ID: <87bmcuwiqe.fsf@bsb.me.uk> References: <0f701b52-56fa-4318-b045-06682c46a6a9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: h2725194.stratoserver.net; posting-host="7d4c02d44b5486a65cf375268271f904"; logging-data="14112"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ytQaIMxERHm5bqAquCSBVpoShAojHz+k=" Cancel-Lock: sha1:ZjaUGPdcoj2M/8dIj4pm5fftiVQ= sha1:4Q55nMRcnTgof8iGfmRLfcmtJI4= X-BSB-Auth: 1.da45a0b8113f7a49743f.20180601175401BST.87bmcuwiqe.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:35151 Jonas Thörnvall writes: > No i thought if i put var output; in main as global, how could it not > be defined further down the chain, because it says undefined. You may be confusing output having the value undefined, and the concept of a name having no binding. When a name can't be resolved (maybe because the programmer forgot to write "var output;") a ReferenceError is raised. When a variable name *can* be resolved but no value has been assigned to it (such as when you write "var output;"), the variable will have the undefined value. This is the sole value of the Undefined type. -- Ben.