// 定义商品类class Product {
constructor(id, name, price) {
this.id = id;
this.name = name;
this.price = price;
}}// 商品数组const products = [
new Product(1, '笔记本电脑', 5000),
new Product(2, '打印机', 1000),
new Product(3, '办公桌椅', 800)];function getProducts() {
return products;}const allProducts = getProducts();console.log(allProducts);
暂时没有评论,来抢沙发吧~