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,
thisrefers to the owner object. - Alone,
thisrefers to the global object. - In a function,
thisrefers to the global object. - In a function, in strict mode,
thisisundefined. - In an event,
thisrefers to the element that received the event. - Methods like
call(), andapply()can referthisto 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"> ...
随机推荐
- Centos中使用Docker部署Apollo
采用微服务开发框架开发项目时会涉及多个系统,如果要更改配置参数需要在多个系统间逐一更改,比较费时,而且容易遗漏,效率低下,次问题可以采用Apollo配置中心的方式解决,下面将介绍如何配置: 准备环境: ...
- linux工具之screen
screen官方网址:http://www.gnu.org/software/screen/ 参考文章:http://man.linuxde.net/screen 简介 Screen是一款由GNU计划 ...
- uboot启动第一阶段分析
一. uboot第一阶段初识 1.1. 什么是uboot第一阶段 1.1.1. 启动os三个阶段 1.1.1.1. bl0阶段 a. 这段代码是三星固化到iROM中,可以查看<S5PV210_i ...
- CF和OF的区别
进位标志CF和溢出标志OF的区别: 有符号数和无符号数只是认为的进行区分,计算机从来不区分有符号数和无符号数.对于运算的数来说,只要符合进位的情况,CF就置1.只要符合溢出的情况,OF就置1.但是后续 ...
- [LeetCode] 113. 路径总和 II
题目链接 : https://leetcode-cn.com/problems/path-sum-ii/ 题目描述: 给定一个二叉树和一个目标和,找到所有从根节点到叶子节点路径总和等于给定目标和的路径 ...
- 输入某年某月某日,判断这一天是这一年的第几天?(可以用 Python 标准 库)
import datetime def dayofyear(): year = input("请输入年份:") month = input("请输入月份:") ...
- PY个快速模
既然这道题是数学题,那就用 PY 吧! 学点东西: print 可以和 c++ 中的 printf 一样快乐的输出格式 另外一点: 这道题可能数据不够强?想想应该有一个 \(0^0 ~\%~ k =0 ...
- 剑指offer 打印从1到最大的n位数
题目描述: 输入数字n,按顺序打印出从1到最大的n位十进制数.比如输入3,则打印出1.2.3一直到最大的3位数999. 分析:注意不能直接输入最大的n位十进制数,因为可能属于大数,这个数无法用int或 ...
- oracle给用户赋dblink权限
create database link 别名(可任意起) connect to 需要连接库的用户名identified by 需要连接库的用户名 using '(DESCRIPTION =(ADDR ...
- vscode 黑屏及类名报错解决方案
1.安装vscode之后打开黑屏,解决方案如下图,右键--属性--兼容性--勾选上 2.vscode 类名总报错 是ES2017的语法修饰器引起vscode警告. 解除的方法如果你使用的typescr ...