object

日常记录

做~自己de王妃 提交于 2020-04-05 22:27:40
react hook useEffect (() => { document.title = `You clicked ${count} times` ; } , [ count ]); // 仅在 count 更改时更新,如果不变 React 会跳过这个 effect ,这就实现了性能的优化 不传第二参数,则如果组件多次渲染(通常如此),则在执行下一个 effect 之前,上一个 effect 就已被清除 如果想执行只运行一次的 effect (仅在组件挂载和卸载时执行),可以传递一个空数组([])作为第二个参数。这就告诉 React 你的 effect 不依赖于 props 或 state 中的任何值,所以它永远都不需要重复执行。这并不属于特殊情况 —— 它依然遵循依赖数组的工作方式。 快速创建数组 let f = length => Array.from ( {length} ) .map (( v , k ) => k ); 进程与线程 一个进程由几个线程组成,进程是资源分配的最小单位,线程是 CPU 调度的最小单位 比如 Chrome 浏览器,可以把每个 tab 看做一个进程,当一个 tab 打开后,会对应开启其内部的线程,如 JavaScript 编译线程、 css 渲染线程、垃圾回收、 service worker 等等 线程快、相互耦合性高,可互通消息

struts2(三)——Ognl 与值栈

牧云@^-^@ 提交于 2020-04-05 16:10:46
什么是OGNL OGNL是Object-Graph Navigation Language的缩写,它是一种功能强大的表达式语言,通过它简单一致的表达式语法,可以存取对象的任意属性,调用对象的方法,遍历整个对象的结构图,实现字段类型转化等功能。 OGNL与EL表达式对比 OGNL对象图导航语言,比EL表达式强大很多倍的语言 EL表达式只能从域中获取数据 OGNL可以调用对象的方法,获取struts的值栈的数据。 OGNL是第三方的表达式语言,用它来获取struts中值栈的数据 OGNL功能 支持运算符(如+-*/) 支持对象方法调用,如xxx.doSomeSpecial(); 支持类静态的方法调用和值访问 支持赋值操作和表达式串联 访问OGNL上下文 操作集合对象 可以直接new一个对象 OGNL使用要素 表达式 根对象 Context对象(非根对象) OGNL入门 OGNL核心OgnlContext,本质就是一个map java程序使用ognl @Test public void test(){ OgnlContext ognlContext = new OgnlContext(); ognlContext.setRoot("aaa"); Object obj = Ognl.getRoot(ognlContext); System.out.println(obj); }

从Java对象布局markword看syncronized的本质

自作多情 提交于 2020-04-05 15:55:15
可以通过以下工具来查看Java对象的布局:JOL=Java Object Layout。 <!-- https://mvnrepository.com/artifact/org.openjdk.jol/jol-core --> <dependency> <groupId>org.openjdk.jol</groupId> <artifactId>jol-core</artifactId> <version>0.10</version> </dependency> 先看下在JVM中,一个引用的长度占用多少字节: import org.openjdk.jol.vm.VM; public class JavaObjectLayout { public static void main(String[] args) { System.out.println("------------VM details---------------"); System.out.println(VM.current().details()); } } 这个details()方法由JOL类库中的HotspotUnsafe类实现: 运行结果: 运行结果中可以看到: 1.JVM是64位的HotSpot 2.默认开启oop(Ordinary Object Pointer,普通对象指针)压缩,可设置JVM参数-XX:

Convert an array of objects to array of the objects' values

南楼画角 提交于 2020-04-05 08:07:16
问题 I am trying to convert this array let orders = [ { amount: '100', user: 'admin', date: 'March 6, 2019' }, { amount: '120', user: 'admin', date: 'March 6, 2019' }, { amount: '80', user: 'admin', date: 'March 7, 2019' }, { amount: '200', user: 'admin', date: 'March 7, 2019' }, ]; to something like this orders = [ ['100', 'admin', 'March 6, 2019'], ['120', 'admin', 'March 6, 2019'], ['80', 'admin', 'March 7, 2019'], ['200', 'admin', 'March 7, 2019'], ]; and I have read that Objects.values()

Convert an array of objects to array of the objects' values

自古美人都是妖i 提交于 2020-04-05 08:05:33
问题 I am trying to convert this array let orders = [ { amount: '100', user: 'admin', date: 'March 6, 2019' }, { amount: '120', user: 'admin', date: 'March 6, 2019' }, { amount: '80', user: 'admin', date: 'March 7, 2019' }, { amount: '200', user: 'admin', date: 'March 7, 2019' }, ]; to something like this orders = [ ['100', 'admin', 'March 6, 2019'], ['120', 'admin', 'March 6, 2019'], ['80', 'admin', 'March 7, 2019'], ['200', 'admin', 'March 7, 2019'], ]; and I have read that Objects.values()

How can I call generic method unknowing instance object type

家住魔仙堡 提交于 2020-04-05 05:24:38
问题 With this code: World w = new World(); var data = GetData<World>(w); If I get w with reflection and this can be of type World , Ambient , Domention , etc. How can I get GetData ??? I only have the instance object: var data = GetData<???>(w); 回答1: var type = <The type where GetData method is defined>; var genericType = typeof(w); var methodInfo = type.GetMethod("GetData"); var genericMethodInfo = methodInfo.MakeGenericMethod(genericType); //instance or null : if the class where GetData is

How can I call generic method unknowing instance object type

孤街浪徒 提交于 2020-04-05 05:24:07
问题 With this code: World w = new World(); var data = GetData<World>(w); If I get w with reflection and this can be of type World , Ambient , Domention , etc. How can I get GetData ??? I only have the instance object: var data = GetData<???>(w); 回答1: var type = <The type where GetData method is defined>; var genericType = typeof(w); var methodInfo = type.GetMethod("GetData"); var genericMethodInfo = methodInfo.MakeGenericMethod(genericType); //instance or null : if the class where GetData is

How to filtering array of objects to another array of objects in javascript? [closed]

拈花ヽ惹草 提交于 2020-04-05 05:17:49
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 9 days ago . I have got two arrays of objects . I want to filtering data based on PermissionObj. This is coming form database. Here is arrays of sub-arrays in the permissionObj . const PermissionObj = { permission: [{ "books": [{ "label": "Can View", "value": "can_view" }] }, { "Journals": [{

javascript对象

青春壹個敷衍的年華 提交于 2020-04-04 21:52:20
定义一个对象 能够使用对象直接量 var o = {name: 'hello'}; 键名加不加引號都能够,可是假设键名不是合法标识符。就必须加引號。 对象的属性之间用逗号分隔,ECMAScript 5规定最后一个属性后面能够加逗号(trailing comma)。也能够不加。可是,ECMAScript 3不同意加入逗号。所以假设要兼容老式浏览器(比方IE 8)。那就不能加这个逗号。 JavaScript原生提供一个Object对象(注意起首的O是大写),全部其它对象都继承自这个对象。Object本身也是一个构造函数。能够直接通过它来生成新对象。 var o = new Object(); // {} Object作为构造函数使用时,能够接受一个參数。假设该參数是一个对象。则直接返回这个对象。假设是一个原始类型的值,则返回该值相应的包装对象。 也能够使用 Object.create() var o3 = Object.create(null); 读写属性 假设使用方括号运算符,键名必须放在引號里面。否则会被当作变量处理。可是,数字键能够不加引號,由于会被当作字符串处理。 方括号运算符内部能够使用表达式,点号不行 o['hello' + ' world'] o[3+3] 使用in运算符检查属性是否声明 查看一个对象本身的全部属性,能够使用Object.keys方法 var o = {

spring aop

拈花ヽ惹草 提交于 2020-04-04 11:11:26
本文引用自 http://www.cnblogs.com/ityouknow/p/5329550.html 什么是AOP AOP(Aspect-OrientedProgramming,面向方面编程),它利用一种称为“横切”的技术,剖解开封装的对象内部,并将那些影响了多个类的公共行为封装到一个可重用模块,并将其名为“Aspect”,即方面。所谓“方面”,简单地说,就是将那些与业务无关,却为业务模块所共同调用的逻辑或责任封装起来,便于减少系统的重复代码,降低模块间的耦合度,并有利于未来的可操作性和可维护性。 AOP使用场景 AOP用来封装横切关注点,具体可以在下面的场景中使用: Authentication 权限 Caching 缓存 Context passing 内容传递 Error handling 错误处理 Lazy loading 懒加载 Debugging  调试 logging, tracing, profiling and monitoring 记录跟踪 优化 校准 Performance optimization 性能优化 Persistence  持久化 Resource pooling 资源池 Synchronization 同步 Transactions 事务 Spring AOP底层技术 Spring提供了两种方式来生成代理对象: JDKProxy和Cglib