JavaScript: x.y.z Associativity, Right or Left?

By Xah Lee. Date: . Last updated: .

fun JavaScript problem. Test your knowledge.

// what's the value of x.y.z()

const x = {
  "y.z": function () {
    return 4;
  },
  "y": {
    "z": function () {
      return 3;
    },
  },
};

console.log(x.y.z());

Try it out in your browser console to see the answer. [see How to Use Browser Console]

BUY
Ξ£JS
JavaScript in Depth

JavaScript in Depth

Basic Syntax

Value Types

Variable

String

Property

Object and Inheritance

Array

Function

Constructor/Class

Iterable 🌟

Misc