<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <script type="text/javascript"> var tool = { a : 'some msg', show : function() { alert(this.a); } } tool.show(); var tool2 = { a : 'msg1', b : { a : 'msg2', show : function() { alert(this.a); } } } tool2.b.show(); </script> </head> <body> </body> </html>
用浏览器打开,分别弹出消息
some msg
msg2
js中没有super关键字,this关键字代表:
this 只能出现在function中,且这个function对应的key所在的 对象就是this
标签:function,msg2,show,some,js,msg From: https://www.cnblogs.com/zno2/p/6128367.html