> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/zh/code/builtin.md).

# 在 Duaer 里使用内置方法和变量

Duaer 在表达式里提供读取数据的变量和按类型调用的方法。Code 节点跑的是普通 JavaScript 和原生 Luxon。
## 表达式和 Code 节点不是同一套

表达式编辑器能用 $json、$("节点名")、$now、$if()，以及挂在字符串、数组、日期上的转换方法。Code 节点不走这套表达式引擎。

Code 节点里如果报 is not a function，先看这个方法是不是只存在于表达式。日期格式化在表达式里可以写 format()，在 Code 节点里要用 Luxon 的 toFormat()。plus() 和 minus() 在表达式里可以写成 (数量, 单位)，在 Code 节点里要写成 { days: 7 }。写成表达式的参数时，Code 节点不一定报错，但结果不是你要的。

$if()、$ifEmpty()、$jmespath() 这类顶层函数只在表达式里。对照见[Duaer 方法和变量对照](/zh/code-examples/methods-variables-reference.md)。

## 按类型打开哪一页

- 当前项、前面的节点、条件和空值：[在 Duaer 表达式里使用快捷方法](/zh/code/builtin/convenience.md)。
- 数组、布尔、日期、数字、对象、字符串：[在 Duaer 里使用数据转换方法](/zh/code/builtin/data-transformation-functions.md)。
- HTTP 节点分页：[在 Duaer 里使用 HTTP 节点分页变量](/zh/code/builtin/http-node-variables.md)。
- JSON 查询：[在 Duaer 里用 JMESPath 查询 JSON](/zh/code/cookbook/jmespath.md)。
## Questions

### Duaer 转换方法能在 Code 节点里用吗？

Duaer 转换方法和 $if()、$jmespath() 属于表达式。Code 节点跑普通 JavaScript 和原生 Luxon。表达式里的 format() 在 Code 节点里改用 toFormat()；plus(7, "days") 改成 plus({ days: 7 })。

### 在 Duaer 里当前项用哪个变量读？

在 Duaer 表达式里，当前项是 $json，文件是 $binary。前面某个节点用 $("节点名").item、first()、last() 或 all()。

