Eval | Qt Qml | Qt 6.11.2
Description: [eval] Usage of eval.

- Qt 6.11
- Qt Qml
- QML Lint Warning and Errors
- Eval
- Qt 6.11.2 Reference Documentation

# Eval

This warning category is spelled `[eval]` by qmllint.

## Do not use eval

### What happened?

You used `eval` in your code.

### Why is that bad?

The `eval` method is slow and potentially dangerous. `eval` executes its argument as if it were its own JavaScript script, which adds some overhead to the execution. The argument passed to `eval` is potentially a vector for remote code execution attacks.

### Example

     import QtQuick

     Item {
         function f() {
             let myString = "x",
             myObject = {
                 x: 10
             },
             value = eval("myObject." + myString);
         }
     }

To fix this warning, rewrite the code so that it doesn't contain any `eval` calls.

     import QtQuick

     Item {
         function f() {
             let myString = "x",
             myObject = {
                 x: 10
             },
             value = myObject[myString];
         }
     }