刚开始学Javascript遇到问题不会了

问题遇到的现象和发生背景

无法运行

问题相关代码,请勿粘贴截图
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
    <script type="text/javascript">
    
    var Student={
        name:"xiaoming",
        age:18,
        chinese_score:150,
        math_score:150,
        avg.function(){
            return (this.chinese_score+this.math_score)/2;
        }
    }
    console.log(Student.name);
    console.log(Student.avg());
</script>
</body>
运行结果及报错内容

Uncaught SyntaxError: Unexpected token '.'
Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

我的解答思路和尝试过的方法
我想要达到的结果

正常运行

avg:function()

前边的定义都是名称:内容,怎么到这里变成点了

img


这里改成 avg:function(){} ,不能用点,点是进行取值操作,对象取值可以用. 也可以用[]
console.log(Student.name)和console.log(Student['name']) 效果是一样的
加油!
如有帮助,望采纳 ^.^


<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<script type="text/javascript">
    var Student={
        name:"xiaoming",
        age:18,
        chinese_score:150,
        math_score:150,
       
    }
    function avg(){
        return (this.chinese_score+this.math_score)/2;
    }
    console.log(Student.name);
    console.log(avg());
</script>
</body>