JS: Dot Notation Associativity, Right or Left

By Xah Lee. Date: . Last updated: .

fun JavaScript problem. Test your knowledge.

// JavaScript quiz.
// what does it print

const y = { z: "z" };

const x = { "y.z": 4, "z": 5, "y": { "z": 3 } };

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

console.log(x[y.z]);
// 5

console.log(x["y.z"]);
// 4

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