The JavaScript this Keyword
https://www.w3schools.com/js/js_this.asp
What is this?
The JavaScript this
keyword refers to the object it belongs to.
It has different values depending on where it is used:
- In a method,
this
refers to the owner object. - Alone,
this
refers to the global object. - In a function,
this
refers to the global object. - In a function, in strict mode,
this
isundefined
. - In an event,
this
refers to the element that received the event. - Methods like
call()
, andapply()
can referthis
to any object.
this in a Method
In an object method, this
refers to the "owner" of the method.
In the example on the top of this page, this
refers to the person object.
The person object is the owner of the fullName method.
return this.firstName + " " + this.lastName;
}
The JavaScript this Keyword的更多相关文章
- [Javascript] delete keyword
delete keyword doesn't actually delete the value but just the reference. var me = { name: { first: & ...
- 专题:点滴Javascript
JS#38: Javascript中递归造成的堆栈溢出及解决方案 JS#37: 使用console.time测试Javascript性能 JS#36: Javascript中判断两个日期相等 JS#3 ...
- JavaScript初学者必看“this”
译者按: JavaScript的this和Java等面向对象语言中的this大不一样,bind().call()和apply()函数更是将this的灵活度进一步延伸. 原文: JavaScript: ...
- Understand JavaScript’s “this” With Clarity, and Master It
The this keyword in JavaScript confuses new and seasoned JavaScript developers alike. This article a ...
- jQuery自定义组件——输入框设置默认提示文字
if (window.jQuery || window.Zepto) { /** * 设置输入框提示信息 * @param options * @author rubekid */ var setIn ...
- U3D——Unity3D的脚本-script入门
Unity3D的基本操作非常easy就能掌握了,接下来就是游戏系统的核心部分:脚本. 什么是Script(脚本)?简而言之,就是使用代码来运行一系列动作命令的特殊文本,它须要编译器来从新解读.U ...
- 用jQuery的ajax的功能实现输入自动提示的功能
注意事项:要使用jQuery首先要把它的包引用进来( <script type="text/javascript" language="javascript&quo ...
- ajax冲刺03
---恢复内容开始--- 1.jq中ajax封装 简单的$.ajax方法使用示例:请关注 传参类型及数据 <!DOCTYPE html> <html lang="en&qu ...
- HTML5 LocalStorage Demo
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
随机推荐
- Java数据结构之栈(Stack)
1.栈(Stack)的介绍 栈是一个先入后出(FILO:First In Last Out)的有序列表. 栈(Stack)是限制线性表中元素的插入和删除只能在同一端进行的一种特殊线性表. 允许插入和删 ...
- P5020货币系统
这个题是2018提高组真题,是一道看不出是背包的背包题. 题干特别长,甚至有些没看懂.题意为给出一组货币面值,然后从这里面用最少的面值数量取代原先的面值.比如3,6直接用3表示.一开始想到了小凯的疑惑 ...
- linux中忘记mysql用户root密码解决方案
1.vim /etc/my.cnf[mysqld]skip-grant-tables ##追加此行,跳过权限表, 2.重启mysqlsystemctl restart mysqld 3.mysql 登 ...
- [LeetCode] 140. 单词拆分 II
题目链接 : https://leetcode-cn.com/problems/word-break-ii/ 题目描述: 给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,在字符 ...
- 大div中,三个小div水平居中
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- AXI总线协议
AXI总线协议 (一).概述 AXI (高性能扩展总线接口,Advanced eXtensible Interface)是ARM AMBA 单片机总线系列中的一个协议,是计划用于高性能.高主频的系统设 ...
- vue data数据变化 页面数据不更新问题
问题: <template> <div class="container"> <div v-for="(item, index) in ar ...
- VB程序设计中Combobox的取值问题
Private a As Double Private Sub Combo1_Click() '1位小数,系数用10 a = Combo1.ItemData(Combo1.ListIn ...
- docker下安装caffe
1.安装docker 2.下载caffe docker镜像 docker pull bvlc/caffe:gpu 可以去https://hub.docker.com/search/?q=SSD%20c ...
- 闲着没事写点啥之springmvc梳理
用户通过浏览器向服务器发送请求,请求被springmvc的前端控制器dispatcherservlet拦截. dispatcherservlet拦截到请求后,会调用handlermapping处理器映 ...