草庐IT

read-eval-print-loop

全部标签

javascript - window[] 和 eval() 之间的区别 - Javascript

我一直在javascript中使用两者...真的不知道有什么区别。谷歌搜索总是显示“窗口对象”或“在javascript中打开一个新窗口”的结果,所以在那里找不到任何东西。eval("v"+e)window["v"+e]有时window对我有用,有时eval有用....那么eval()和window[]有什么区别呢?抱歉新手问题!诺曼 最佳答案 另一点尚未解决的是,eval将使用调用者变量环境解析变量引用,例如:varfoo="global";(function(){varfoo="local";alert(eval("foo"))

javascript - Angular2 - 类型错误 : Cannot read property 'Id' of undefined in (Typescript)

我收到以下错误:angular2.dev.js:23925EXCEPTION:TypeError:Cannotreadproperty'Id'ofnullin[{{product.Id}}inProductEditComponent@0:68]抛出://Product-edit.component.ts:import{Component}from'angular2/core';import{IProduct}from'./product'import{ProductService}from'./product.service'import{RouteParams}from'angula

javascript - 如何让外部代码 'safe' 运行?只是禁止 eval()?

我希望能够让社区成员提供他们自己的javascript代码供其他人使用,因为用户的想象力集体远远超过我所能想到的。但这引发了固有的安全问题,特别是当目的是允许外部代码运行时。那么,我可以禁止提交中的eval()并结束它吗?还是有其他方法可以评估代码或在javascript中引起大规模panic?还有其他一些事情是不允许的,但我主要担心的是,除非我可以阻止字符串被执行,否则我为特定方法设置的任何其他过滤器都可以被绕过。可行,还是必须求助于作者提供网络服务接口(interface)? 最佳答案 自HTML5现在可以使用了sandbox对

javascript - react - 类型错误 : Cannot read property 'props' of undefined

我正在尝试创建一个能够删除列表中项目的点击事件,但是当我点击它时,我得到“类型错误:无法读取未定义的属性‘props’”。我尽量坚持使用ES6,而且我很确定在某处绑定(bind)“this”是一件好事,但我尝试了很多地方但都没有成功。importReact,{Component}from'react';import'./App.css';classAppextendsComponent{render(){return();}}classStreetFighterextendsComponent{constructor(props){super(props);this.state={ch

javascript - 导入 anuglar2/forms 导致 "Cannot read property ' 未定义注释”

我正在尝试创建简单的表单,如http://angularjs.blogspot.no/2015/03/forms-in-angular-2.html中所述,但是当我添加从'angular2/forms'导入{forms,required};在崩溃中TypeError:Cannotreadproperty'annotations'ofundefinedTypeError:Cannotreadproperty'annotations'ofundefinedatReflectionCapabilities.System.register.execute.$__export.annotatio

javascript - ES6 : No source code for webpack "cheap-module-eval-source-map" and "cheap-module-source-map" only ** WEBPACK FOOTER **

它曾经有效。现在,当我添加一个断点时:saveSnippet:(title,imageUrl,role)=>{debugger;...chrome(53)中的结果是:我尝试使用它并将配置更改为'cheap-module-source-map'和'eval-source-map'和'source-map'。现在只有'eval-source-map'和'source-map'可以工作。webpack.config.js(Webpack1.13.2):varpath=require('path')varwebpack=require('webpack')varCompressionPlugi

javascript - promise - TypeError : Cannot read property 'then' of undefined

我想我只需要另一双眼睛看这个,因为我无法得到我在这里缺少的东西。$scope.checkout=function(form){//somecodeherefunctioncheckoutErrorHandler(error){//somecodehere}functiondisplaySuccessMessage(){$scope.success=true;cartService.emptyCart();}checkoutService.makePayment($scope.payment).then(function(i){//somecodeherecheckoutService.

javascript - 开 Jest + 火力地堡 : TypeError: Cannot read property 'defineProperties' of undefined

我目前正在做一个ReactNative项目,想使用FirebaseJSSDK。为了熟悉它的所有API,我想用Jest编写一些学习测试。这是我的测试:importFirebasefrom'firebase';describe('Firebase',function(){it('shouldwork',function() {expect(null).toBeNull()})});不幸的是我收到了这个错误:●测试套件运行失败TypeError:Cannotreadproperty'defineProperties'ofundefinedatnode_modules/firebase/app

javascript - Window.print 问题

这是我的问题我有一个实现window.print的代码,但问题是当我关闭窗口打印并返回到我的页面时,我的打印按钮不再起作用。$(function(){$('#button1').click(function(){$('head').append('assets/weekly/style/weekly.css"type="text/css"/>');varprintContents=document.getElementById('data').innerHTML;varoriginalContents=document.body.innerHTML;document.body.inne

javascript - 执行 Action 时 redux 出错 : Uncaught type error: cannot read property 'type' of undefined

刚刚接触React。我想这是一个基本问题,但我不明白为什么reducer没有被解雇或更新状态:我的HomeView.js:....const{localeChange,counter,locale}=this.propsreturn(increment(7)}>Increment.....)constmapStateToProps=(state)=>({locale:state.locale,counter:state.counter})exportdefaultconnect(mapStateToProps,{localeChange,increment})(HomeView)我的r