还有哪些其他语言像 JavaScript 一样是松散类型的?
我了解到 JavaScript 是一种“松散类型”语言。
还有哪些其他语言是“松散类型”的?
I learned that JavaScript is a "loosely-typed" language.
What other languages are "loosely-typed?"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有不同意 关于“松散”或“弱类型”的确切含义,但是,就通常理解而言,“松散类型”指的是一种更宽容的语言类型规则,甚至可能将类型从一种类型隐式转换为另一种类型
。 ”维基百科:
根据这个定义,JavaScript 是松散类型的(即与强类型相反),因为大多数 JavaScript 运算符会在必要时强制其操作数。
例如:
另一个松散类型语言示例是 C。
请注意,JavaScript 也是动态类型的。这意味着值的类型绑定到值并在运行时检查,而不是绑定到变量并在编译时检查。实际上,类型检查是“动态”(即在运行时)执行的,而不是“静态”(即在编译时)执行的。
动态语言示例:
There is disagreement about exactly what "loose" or "weak typing means, however, in so far as commonly understood, "loose typing" refers to a language that has more forgiving typing rules, and might even implicitly convert types from one type to another.
From Wikipedia:
According to this definition, JavaScript is loosely-typed (ie. the opposite of strongly typed) because most of JavaScript operators will coerce their operands if necessary.
For example:
Another example of a loosely-typed language example is C.
Note that JavaScript is also dynamically typed. This means that the type of a value is bound to the value and checked at runtime, instead of being bound to the variable and checked at compile time. In effect type checking is performed "dynamically" (ie at runtime) as opposed to "statically" (ie. at compile time).
Examples of dynamic languages:
PHP 与PERL 也是弱类型的。
PHP & PERL are also weakly typed.
许多解释性语言如php或pearl,总之松散类型语言是一种不需要定义变量的语言
many of the interpreted languages such as php or pearl, in short a loosely-typed language is a language that does not require a variable to be defined