跳到主要内容

2. 语言基础

本章说明脚本的基本组成:记号如何书写、值有哪些类型、变量如何绑定,以及表达式如何计算。

var price = 20;
var quantity = 3;
var total = price * quantity;
return {"total": total, "discounted": total >= 50};

结果为 {"total":60,"discounted":true}。变量保存值,表达式计算新值,对象组织结果字段。