<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>Title</title></head><body></body><script> ???function show() { ???????console.log(this) ???} ???show(); //window object ???new show(); //object ???j = { ???????name:‘ldq‘, ???????age:18, ???????info:function () { ???????????console.log(`我的名字是${name},我的年龄是${age}`) ???????????console.log(123) ???????} ???}; ???console.log(j); ???new j.info(); ???function show(name,age) { ???????this.name = name; ???????this.age = age; ???????this.fun1=function () { ???????????console.log(`我的名字是${this.name},我的年龄是${this.age}`) ???????} ???} ???obj = new show(‘ldq‘,18) ???obj.fun1()</script></html>
js 函数与类的区别
原文地址:https://www.cnblogs.com/ldq1996/p/8371073.html