JavaScript 定义数组和对象的方法推荐
当然还有其他方法,这个只是推荐方法,精简高效:
数组定义:
var arr = [1, 2, 3.14, 'Hello', null, true];
对象定义:
var person = {
name: 'Bob',
age: 20,
tags: ['js', 'web', 'mobile'],
city: 'Beijing',
hasCar: true,
zipcode: null
};