// 示例代码:使用 length 属性获取数组和字符串的长度
// 获取数组的长度
let array = [1, 2, 3, 4, 5];
console.log(array.length); // 输出: 5
// 解释:length 属性返回数组中元素的数量。
// 获取字符串的长度
let string = "Hello, world!";
console.log(string.length); // 输出: 13
// 解释:length 属性返回字符串中字符的数量,包括空格和标点符号。