当我们写(用某种语言或其他语言):
lengthOf(n)
Run Code Online (Sandbox Code Playgroud)
我们认为它是英语"填空"结构的缩写,例如:
length of __
Run Code Online (Sandbox Code Playgroud)
但是当我们写这样的东西时:
isAnInteger(n)
appendTo(n,m)
Run Code Online (Sandbox Code Playgroud)
我们想到的句子如下:
__ is an integer
append ___ to ___
Run Code Online (Sandbox Code Playgroud)
因此,允许函数调用表达式似乎更自然:
(n)isAnInteger
append(n)to(m)
Run Code Online (Sandbox Code Playgroud)
'函数名称'是这样的:
_isAnInteger
append_to_
Run Code Online (Sandbox Code Playgroud)
任何人都可以命名现有的编程语言吗? 我知道面向对象的语言让对象成为前面的一个参数,但我想知道更灵活的语法.
Javascript:The Definitive Guide(2011)有这个例子(p.186),它不能在严格模式下工作,但没有说明如何在严格模式下实现它 - 我可以想到要尝试的东西,但我想知道最佳实践/ security/performance - 在严格模式下执行此类操作的最佳方法是什么?这是代码:
// This function uses arguments.callee, so it won't work in strict mode.
function check(args) {
var actual = args.length; // The actual number of arguments
var expected = args.callee.length; // The expected number of arguments
if (actual !== expected) // Throw an exception if they differ.
throw Error("Expected " + expected + "args; got " + actual);
}
function f(x, y, z) {
check(arguments); // Check that the actual # of args …Run Code Online (Sandbox Code Playgroud)