Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25096

Re: What does x.y.z mean?

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: What does x.y.z mean?
Date 2014-06-27 09:46 +0000
Organization A noiseless patient Spider
Message-ID <lojei7$i56$1@dont-email.me> (permalink)
References <a93c4421-8f80-4f76-ab42-a034af382a20@googlegroups.com>

Show all headers | View raw


On Wed, 25 Jun 2014 10:33:09 -0700, bit-naughty wrote:

> I always had this figured out:
> 
> x is an object, of which y is a method that returns an object itself,
> and z is a property or method of *that* object - am I right in this?
> 
> Also, what happens in the case of an object literal? Is y an object
> inside x, and z an object inside y? Or am I completely mistaken?

Stuff like this is so difficult to test for yourself isn't it.

<!doctype html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>x.y.z</title>
    <script type="application/javascript">
      function gebi(x) { return document.getElementById(x); }
      var x = JSON.parse('{"y":{"z":"zed"}}');
      function stuff() {
        gebi("tofx").value = typeof( x );
        gebi("tofxy").value = typeof( x.y );
        gebi("tofxyz").value = typeof( x.y.z );
        gebi("strx").value = x.toString();
        gebi("strxy").value = x.y.toString();
        gebi("strxyz").value = x.y.z.toString();
      }
    </script>
  </head>
  <body onload="stuff();">
    <pre>
      var x = JSON.parse('{"y":{"z":"value"}}');
    </pre>
    <p>
      typeof x = <input id="tofx"><br>
      typeof x.y = <input id="tofxy"><br>
      typeof x.y.z = <input id="tofxyz"><br>
      x.toString() = <input id="strx"><br>
      x.y.toString() = <input id="strxy"><br>
      x.y.z.toString() = <input id="strxyz"><br>
    </p>
  </body>
</html>

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.javascript | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

What  does x.y.z mean? bit-naughty@hotmail.com - 2014-06-25 10:33 -0700
  Re: What  does x.y.z mean? Gregor Kofler <usenet@gregorkofler.com> - 2014-06-25 21:41 +0200
    Re: What  does x.y.z mean? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-26 11:09 +0200
    Re: What  does x.y.z mean? bit-naughty@hotmail.com - 2014-06-26 06:25 -0700
      Re: What  does x.y.z mean? John Harris <niam@jghnorth.org.uk.invalid> - 2014-06-26 14:47 +0100
        Re: What  does x.y.z mean? John Harris <niam@jghnorth.org.uk.invalid> - 2014-06-27 09:52 +0100
  Re: What  does x.y.z mean? Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-27 09:46 +0000

csiph-web