【复习】javascript this的指向

[JS]面试八股文 答:闭包(Closure)是指“一个函数及其词法环境(即该函数被定义时的作用域)的组合”。简单来说,闭包让一个函数可以访问其外部作用域中的变量,即使在外部函数执行完毕后,这些变量依然可以被内部函数访问和操作在调用一个函数A时返回了一个函数B,并在B中访问了A中的变量,就会形成一个闭包,在A的执行上下文中会保存一个closure(A)的对象,并将B中访问的变量保存在堆中。闭包其实只是一个绑定了执行环境的函数。 阅读详情

this的指向,是当我们调用函数的时候确定的,调用的方式不同决定this的指向不同。this一般指向调用者

调用方式this指向示例
普通函数调用window
function fn() {
            console.log('这是一个函数要执行的代码');
        }

fn();

 

构造函数调用实例对象,原型对象中的方法也指向实例对象
function Person (uname, age) {
			// 属性
			this.uname = uname;
			this.age = age;
			// 方法
			// this.chi = function () {
			// 	console.log('吃饭');
			// }
		}

 

对象方法调用该方法所属对象
var obj = {
			taiji : function () {
				console.log(this);
			}
		}
		obj.taiji();

 

事件绑定方法绑定事件对象
var btn = document.getElementById('btn');
		btn.onclick = function () {
			console.log(this);
		}

 

定时器函数window
window.setInterval(function () {
			console.log(this);
		}, 1000);

 

立即执行函数window
(function () {
			console.log(this);
		}())

 

 

python 爬虫 xpath 存储到数据库 参考 阅读详情

相关推荐

从零到一:RV1126与IMX415的硬件交响曲——深入解析Linux IPC摄像头的硬件调试艺术

本文深入解析了RV1126与IMX415组合的Linux IPC摄像头硬件调试技术,涵盖硬件接口检查、设备树配置、驱动加载验证及ISP调优等关键步骤。通过详细的操作指南和常见问题解决方案,帮助开发者快速掌握摄像头调试技巧,提升开发效率。

weixin_29161785的博客 985

复习js中的this指向

1.函数在方法上的指向 // 在方法中使用this,方法是指放在对象里的函数 const obj = { foo:function(){ console.dir(this); } } obj.foo() 在es6中,方法的另一种写法是否会有所不同呢?来看一下: ...

方寸间的博客 189

IPD实战指南:如何运用SPAN模型精准定位高潜力市场并优化资源配置

本文是IPD实战指南,详细解析了如何运用SPAN模型进行市场分析与战略决策。文章通过四步实战法,指导企业科学定义细分市场、量化评估吸引力与竞争力,并绘制矩阵以制定精准的资源配置策略,从而跳出红海竞争,将资源聚焦于高潜力市场。

weixin_29306317的博客 75

js基础复习之this指向

/* * 解析器在调用函数每次都会向函数内部传递进一个隐含的参数, * 这个隐含的参数就是this,this指向的是一个对象, * 这个对象我们称为函数执行的 上下文对象, * 根据函数的调用方式的不同,this会指向不同的对象 * 1.以函数的形式调用时,this永远都是window * 2.以方法的形式调用时,this就是调用方法的那个对象 */ function fun()...

所学所思 526

全栈开发指南:从前端到后端的全面掌握

全栈开发人员(Full Stack Developer)是指能够处理前端和后端开发工作的开发人员。他们需要掌握各种技术和工具,能够独立完成从需求分析、设计、开发到部署的整个流程。这篇博客将详细介绍全栈开发涉及的各个方面,为您提供从入门到进阶的指导。

Where there is a will, there is a way ! 3453

5分钟搞懂深度学习如何革新声源定位:从GCC-PHAT到DNN的实战对比

本文深入对比了深度学习与传统GCC-PHAT方法在声源定位领域的实战表现。通过具体实验数据,展示了DNN模型在强混响、低信噪比等复杂场景下,如何实现定位准确率的显著提升,并探讨了其数据驱动范式带来的鲁棒性优势与工程部署挑战。

3a9bq4r8t2y的博客 223

关于js中this指向复习

简单说this指向 谁调用指向谁 1.对象.方法() 中,方法中的this指向的就是对象 2.普通函数中的 this 指向window,这是因为 window 是JS中的顶级对象,可以通过window点的形式访问在全局作用域中定义的任何变量或方法 3. 构造函数中的 this 指向实例对象 ...

LRQQHM的博客 1683

可信数据空间:可信空间、区域功能节点、业务功能节点、连接器的关联关系

可信数据空间通过分层架构实现安全数据共享:可信空间作为顶层制定全局规则;区域功能节点协调辖区内功能节点协作;功能节点提供具体数据服务;连接器作为唯一通信通道确保安全交互。系统采用"规则自上而下约束,数据自下而上流动"机制,通过分层治理和标准化连接,在保证数据主权的同时实现跨域协作,具有策略分级执行、去中心化治理等特性,支持灵活扩展业务场景。

友莘居士的博客 1688

JS数据类型、数组、this指向复习

总结来说,面试成功=基础知识+项目经验+表达技巧+运气。我们无法控制运气,但是我们可以在别的地方花更多时间,每个环节都提前做好准备。面试一方面是为了找到工作,升职加薪,另一方面也是对于自我能力的考察。能够面试成功不仅仅是来自面试前的临时抱佛脚,更重要的是在平时学习和工作中不断积累和坚持,把每个知识点、每一次项目开发、每次遇到的难点知识,做好积累,实践和总结。点击这里领取Web前端开发经典面试题。

rt3Dmax9的博客 858

【附代码】SSVEP解码算法 - 扩展典型相关分析(eCCA)

本文主要对SSVEP解码算法-eCCA进行复现和测试。本文提供程序的所有代码,只要在Matlab上即可运行。读者可以根据程序自主调整,方便学习以及初学者更好地了解SSVEP的经典算法。

计算机小白 1337

基于MATLAB的最大重叠离散小波变换(MODWT)算法详解

最大重叠离散小波变换(Maximal Overlap Discrete Wavelet Transform, MODWT)是DWT的重要改进形式,由Percival和Walden等人在20世纪90年代系统提出并完善。MODWT通过消除下采样操作,采用样本平移不变的分解方式,解决了DWT的多个固有缺陷。MODWT的核心创新在于取消下采样环节。与DWT每级分解后对滤波输出进行二分下采样不同,MODWT在每一级都使用相同的滤波器,但通过插入零值的方式调整滤波器系数,保持每级系数数量与原始信号相同。

qq_42212808的博客 115

JavaScript复习,this指向、原型链、变量提升、作用域、闭包

文章目录 函数中this指向问题 原型 变量/函数 提升 全局执行上下文: 测试题 var可重复声明 作用域 闭包 更深入理解闭包的原理 闭包的作用 终极题目 ES5的继承

ronghwa_lu 3782

【CANdelaStudio编辑CDD】-21.2-创建OBD诊断$03,$07,$0A和$04服务以及OBD DTC

案例背景(共11页精讲):创建OBD诊断$03,$07,$0A和$04服务;以及OBD DTC。 在《【ISO15031_OBD诊断】-3.1-$03服务Request emission-related diagnostic trouble codes理论部分https://blog.youkuaiyun.com/qfmzhu/article/details/122157513》, 《【ISO15031_OBD诊断】-7.1-$07服务Request emission-related diagnostic trou

「汽车电子助手」的博客 1697

js复习----this及this指向问题

上面有说到,当调用方法getName()时其this指向该方法所在对象obj,所以当对象的方法是一个普通函数是很好判断其this就是该对象。不难看出this这个关键字和函数是息息相关的,而它的指向又尤为关键,因为this的目的就是帮助我们优雅的传递一个对象。不难看到此时obj中的this就是指向了window,所以此时的在obj中是箭头函数的方法就指向了window。对于情况6有必要进行详细的探讨,试想一种情况如果在一个对象中声明了一个方法,而这个方法是一个箭头函数时,此时this会如何指向。

sorrymaker1998的博客 191

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

JS复习(7)——JS中的大难题this的指向

关于this的指向问题,记住最核心的一句话:哪个对象调用了函数,函数里面的this就指向哪个对象 this的指向分为四种: 普通函数的this指向全局对象window ss ss ss 普通函数中的this指向全局对象 console.log(this); //window //普通函数种 function fn() { console.log(this) //window } fn() //声明函数中 var f = fu

qq_45814762的博客 304

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

JS复习-12-自执行函数、this指向及改变

自执行函数 函数调用的一种方式 function fn() {}, fn() 语法: 1. (function () {})() 2. ~function () {}() 3. !function () {}() 作用: 一般是单独书写 js 文件的时候使用 => 为了保护变量不污染全局 => 每一个 js 文件里面初始化使用一个自执行函数包裹 => 把需要别的文件使用的变量挂载在全局

qq_36158581的博客 589

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

JS数据类型、数组、this指向复习,web前端开发薪资

分享一套阿里大牛整理的前端资料给大家,点击前端校招面试题精编解析大全即可免费下载既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化![外链图片转存中…(img-9CraQt3G-1712166530019)]由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)

2401_84097745的博客 1083

JS数据类型、数组、this指向复习(1)

技术是没有终点的,也是学不完的,最重要的是活着、不秃。零基础入门的时候看书还是看视频,我觉得成年人,何必做选择题呢,两个都要。喜欢看书就看书,喜欢看视频就看视频。最重要的是在自学的过程中,一定不要眼高手低,要实战,把学到的技术投入到项目当中,解决问题,之后进一步锤炼自己的技术。技术学到手后,就要开始准备面试了,找工作的时候一定要好好准备简历,毕竟简历是找工作的敲门砖,还有就是要多做面试题,复习巩固。有需要面试题资料的朋友点击这里可以领取。续更新!**如果你觉得这些内容对你有帮助,可以扫码获取!!

2401_84092666的博客 325

JavaScript高级复习03-this的三种指向,上下文调用,闭包,递归函数

this的三种指向,上下文调用,闭包,递归函数

m0_64526818的博客 492

JS复习-14-箭头函数及其this指向

ES6 的箭头函数 一种新的函数定义方式,对于函数表达式的简写方式(匿名函数) + 匿名函数 => var fn = function () {} => var obj = { fn: function () {} } => setTimeout(function () {}, 0) => setinterval(function () {}, 0) => [].forEach(function () {})

qq_36158581的博客 209

js 面试题 持续更新

子类的构造方法中必须调用super方法,且只有在调用了super()之后才能使用this,因为子类的this对象是继承父类的this对象,然后对其进行加工,而super方法表示的是父类的构造函数,用来新建父类的this对象。(1)原型链继承:让一个构造函数的原型是另一个类型的实例,那么这个构造函数new出来的实例就具有该实例的属性。(4)根据构造函数返回的类型判断,如果是值类型,则返回对象,如果是引用类型,就要返回这个引用类型。(1)原型是普通的对象,是构造函数的实例共享属性和方法;

qq_36529240的博客 304

javascript中this指向问题

之前在开发vue的时候,我经常碰到这样的问题: 在$http.post或者get内部的回调函数中无法使用this.xxx来获取data中的值或者改变data中的值 解决的方法就是在post或get外部 let that = this 从而在内部就能使用that.xxx来获取data中的值 之前知其然而不知其所以然,今天在复习JavaScript知识的时候梳理了一下this的有关知识 首先致谢阮一峰...

阿波罗吹雪的博客 561

Web 版翻译者资料库

本项目是桌面版《翻译者资料库》的 Web 移植版,基于 Spring Boot 3.3、Thymeleaf、Bootstrap 5.3 与 MySQL 8.0 构建。它面向翻译写作提供资料、词汇、句库、文本工具、对照制作、查找、备份恢复及旧库迁移等功能,完整继承桌面版核心业务规则,支持一键启动与离线访问。

howard2005的专栏 149
上一篇: 【复习】javascript 原型对象,对象原型,原型对象和原型中的构造函数(constructor)
下一篇: 【复习】call,apply,bind三个方法的异同
谭CV
博客等级 码龄9年 73粉丝 85原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值