我知道this
可能是javascript中第二个被问到最多的东西,就在浮点运算之后.
我大致知道如何this
工作的,以及它如何影响箭头功能.call()
,.apply()
和.bind()
.我以为我理解了它的一切.但我不.
在Web浏览器中,按预期document.createElement("div").classList.add("c")
产生undefined
.然而,这个表达令人惊讶地是一个错误.
(true && document.createElement("div").classList.add)("c")
Run Code Online (Sandbox Code Playgroud)
我预计它会是一样的,但它确实如此
Uncaught TypeError: Illegal invocation
at <anonymous>:1:54
Run Code Online (Sandbox Code Playgroud) 让我们考虑以下示例:
String s = str.replaceAll("regexp", "$1");
Run Code Online (Sandbox Code Playgroud)
有些语言让我们指定\U$1
的地方$1
,其将匹配用大写字母组.如何使用Java实现相同的目标?
我知道我们可以使用Pattern
类并获取组并将其转换为大写,但这不是我想要的.我想改变$1
完成工作的东西.
我也尝试过:
String s = str.replaceAll("regexp", "$1".toUpperCase());
Run Code Online (Sandbox Code Playgroud)
但它看起来"$1".toUpperCase()
是,"$1"
而不是匹配.我确认使用:
String s = str.replaceAll("regexp", method("$1"));
// method declared as method()
private static String method(String s) {
System.out.println(s); // prints "$1"
return s;
}
Run Code Online (Sandbox Code Playgroud)
甚至在Java中是否允许?
编辑:
String s = "abc";
System.out.println(s.replaceAll("(a)", "$1")); // should print "Abc"
Run Code Online (Sandbox Code Playgroud)
编辑可能的DUPE:
我不是在寻找的方式使用m.group()
,是否有可能使用类似\U$1
的地方$1
有replaceAll()
我见过有人这样做:
usort($array, function() {
//...
});
Run Code Online (Sandbox Code Playgroud)
如何使用自己的函数编写类似的实现?例如:
runIt(function() {
//...
});
Run Code Online (Sandbox Code Playgroud)
和实施runIt
:
function runIt() {
// do something with passed function
}
Run Code Online (Sandbox Code Playgroud) 我试图了解Spring AMQP。我不能引起交易的注意。
交易的用例是什么?它与JTA相似吗?为什么有人回滚一个Message
?
class MyClass{
static void aut(int i) {}
static void aut(Integer i) {}
static void vararg(int... ia) {}
static void vararg(Integer... ia) {}
public static void main(String args[]) {
aut(1); // compiles successfully
vararg(1); // The method vararg(int[]) is ambiguous for the type MyClass
}
}
Run Code Online (Sandbox Code Playgroud)
我无法理解为什么vararg(1)
会抛出错误.
我们每周对计算机系统漏洞进行测试,其中包含以下问题:
以下函数是在32位x86系统上运行的程序的一部分;编译器不会更改堆栈上变量的顺序。
void function(char *input) {
int i = 1;
char buffer[8];
int j = 2;
strcpy(buffer,input);
printf("%x %x %s\n",i,j,buffer);
}
Run Code Online (Sandbox Code Playgroud)
通过输入参数传递给函数的可能会使应用程序崩溃的字符串的最小长度是多少?
a)10 b)11 c)12 d)13
我编写了一个main
调用的函数,void function(...
并使用编译了程序,gcc -m32 test.c -o test
因为我在64位计算机上。下面是主要功能:
int main(int argc, char *argv[]) {
function(argv[1]);
return 1;
}
Run Code Online (Sandbox Code Playgroud)
并经过输入测试:
~/Dir:./test 1234567
1 2 1234567
~/Dir:./test 12345678
1 2 12345678
~/Dir:./test 123456789
1 2 123456789
*** stack smashing detected ***: <unknown> terminated
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)
只要输入123456789
参数作为参数,就会检测到堆栈粉碎,因此该问题的答案应该是,9
但是没有选择的选项9 …
我正在尝试PUT
在php中声明HTTP 变量。这是我的代码:
<?php
${"_" . $_SERVER['REQUEST_METHOD']} = /* What should be here? */;
?>
Run Code Online (Sandbox Code Playgroud)
我试过了,var_dump($_SERVER)
但其中不包含使用ajax请求发送的数据。我确定没问题$.ajax()
。
java ×3
php ×2
c ×1
http ×1
javascript ×1
regex ×1
security ×1
spring ×1
spring-amqp ×1
this ×1