title: Javascript Correct way to access parent variable
body: <p>Qt specifies below code in <a href="https://doc.qt.io/qt-5/qtquick-performance.html" rel="nofollow noreferrer">https://doc.qt.io/qt-5/qtquick-performance.html</a>. accumulatedValue variable is accessed as &quot;root.accumulatedValue&quot; and just &quot;accumulatedValue&quot;. Just curious to understand What is the correct way to access parent variables in such situations.</p>
  <pre><code>// good.qml
  import QtQuick 2.3
  
  Item {
      id: root
      width: 200
      height: 200
      property int accumulatedValue: 0
  
      Text {
          anchors.fill: parent
          text: root.accumulatedValue.toString()
          onTextChanged: console.log(&quot;text binding re-evaluated&quot;)
      }
  
      Component.onCompleted: {
          var someData = [ 1, 2, 3, 4, 5, 20 ];
          var temp = accumulatedValue;
          for (var i = 0; i &lt; someData.length; ++i) {
              temp = temp + someData[i];
          }
          accumulatedValue = temp;
      }
  }
  </code></pre>