您的位置:首页 > Web前端 > JQuery

jquery 复制json对象和json对象集合

2016-01-24 16:59 696 查看
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(function () {
var classList = [
{
classId: 1, className: '一班', students: [
{ studentId: 1, studentName: '张三' },
{ studentId: 2, studentName: '李四' }
]
},
{
classId: 2, className: '二班', students: [
{ studentId: 3, studentName: '王五' },
{ studentId: 4, studentName: '马六' }
]
}
]
var classDemo = {
classId: 1, className: '一班', students: [
{ studentId: 1, studentName: '张三' },
{ studentId: 2, studentName: '李四' }
]
}
var newClassList = jQuery.extend(true, [], classList);//复制对象集合
var newClassDemo = jQuery.extend(true, {}, classDemo);//复制对象
});
</script>
</head>
<body>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息