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"> ...
随机推荐
- CM使用MySQL数据库预处理scm_prepare_database.sh执行报错:java.sql.SQLException: Access denied for user 'scm'@'hadoop101.com' (using password: YES)
1.报错提示: [root@hadoop101 ~]# /opt/module/cm/cm-/share/cmf/schema/scm_prepare_database.sh mysql cm -hh ...
- 嘉馨学姐又双叒叕来吃包子了 QDUOJ 模拟 尺度法
嘉馨学姐又双叒叕来吃包子了 QDUOJ 模拟 尺度法 点我进入OJ题目详情 题意 给你一串数,让你求长度最长的子串,这个字串满足里面没有重复出现的数字. 解题思路 使用一个标记数组,来标记每个数的第一 ...
- c++多线程并发学习笔记(2)
等待一个时间或其他条件 在一个线程等待完成任务时,会有很多选择: 1. 它可以持续的检查共享数据标志(用于做保护工作的互斥量),直到另一个线程完成工作时对这个标志进行重设.缺点:资源浪费,开销大 2. ...
- 微信小程序获得微信头像和昵称
微信小程序之登录态的探索 { wx.getSetting({ success: res => { if (res.authSetting && res.authSetting[' ...
- 如何查看Win10开机运行了多长时间 - Windows10.Pro
原文:如何查看Win10开机运行了多长时间 - Windows10.Pro 方法一:使用Windows PowerShell命令查看 以管理员身份运行Windows PowerShell,在打开的“管 ...
- 吴恩达深度学习:2.1Logistic Regression逻辑回归及其损失函数
1.Logistic Regression是一个二元分类问题 (1)已知输入的特征向量x可能是一张图,你希望把它识别出来,这是不是猫图,你需要一个算法,可以给出预测值,更正式的y是一个概率,当输入特征 ...
- 简单的物流项目实战,WPF的MVVM设计模式(二)
往Models文件添加一个类,ConnectObject /// <summary> /// 链接数据库字符串 /// </summary ...
- 锋利的jQuery ——jQuery选择器(二)
一.jQuery选择器 1)CSS选择器 CSS选择器有:1>标签选择器 E{CSS规则} 2>ID选择器 #ID{CSS规则} 3>类选择器 E.className{CSS ...
- [七月挑选]使用hexo建立主题,并发布到github
title: 使用hexo建立主题,并发布到github 根据hexo官网的概述和hexo官网的建站,搭建最开始的hexo博客. 1.环境预先安装好node.js和git 2.npm安装hexo: $ ...
- 安装sysbench,报错"Could not resolve 'ports.ubuntu.com'"
在ubuntu系统中安装sysbench时报错“Could not resolve 'ports.ubuntu.com'”怎么办呢? 安装时报错: 亲测可用的方法: 修改 resolv.conf 文件 ...