这是什么意思,JavaScript是“动态的”? [英] What does it mean that JavaScript is "dynamic"?

查看:193
本文介绍了这是什么意思,JavaScript是“动态的”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从不同的来源阅读(例如wiki,文章等)编程意义上的动态意义。 维基百科讨论了动态编程语言在运行时如何执行某些编程行为(而不是静态的编译时间)语言),但他们的解释是模糊的,并谈论这些行为在所有编程语言的难度,复杂程度和性能成本方面如何变化。



所以关于JavaScript具体来说,这是什么意思,它是动态的?



我可能完全错了,但也要了解JavaScript是一种动态类型的语言,因为你没有状态实例化变量/函数之前的类型(例如var,函数jsFunction()),而不是静态类型的语言,如Java,在实例化变量/函数之前定义类型(例如int var,public int function())。 / p>

这是否与这些有关?

解决方案

大多数语言具有动态行为的一些方面。即使静态类型的语言也可以具有可以包含不同数据类型的动态或变体数据类型。



JavaScript被称为动态语言,因为它不仅具有一些动态方面,几乎一切都是动态的。



所有变量都是动态的(无论是类型还是存在),甚至代码都是动态的。您可以在运行时创建新变量,并且在运行时确定变量的类型。您可以随时创建新功能,或替换现有功能。当在浏览器中使用时,在加载更多脚本文件时添加代码,并且您可以随时加载更多文件。



现在JavaScript在许多实现中被编译,并且在后台生成静态代码和静态类型。但是,行为仍然是动态的,当编译器发现动态方面不用于特定对象时,编译器才会生成静态类型。


I've read from different sources (e.g. wiki, articles, etc.) what dynamic in a programming sense means. Wikipedia talks about how dynamic programming languages execute certain programming behaviors at runtime (as opposed to compile time for static languages), but their explanation is vague and talks about how these behaviors vary in degree of difficulty, complexity, and performance costs for all programming languages.

So with respect to JavaScript specifically, what does it mean that it's dynamic?

I may be completely wrong on this, but also understand JavaScript to be a dynamically typed language since you don't have state the type before instantiating a variable/function(e.g. var, function jsFunction()) as opposed to a statically typed language like Java where you define a type before instantiating a variable/function(e.g. int var, public int function()).

Does this have to do with any of this?

解决方案

Most languages have some aspect of dynamic behaviour. Even statically typed languages can have a dynamic or variant data type that can contain different data types.

JavaScript is called a dynamic language because it doesn't just have a few dynamic aspects, pretty much everything is dynamic.

All variables are dynamic (both in type and existance), and even the code is dynamic. You can create new variables at runtime, and the type of variables is determined at runtime. You can create new functions at any time, or replace existing functions. When used in a browser, code is added when more script files are loaded, and you can load more files any time you like.

Nowadays JavaScript is compiled in many implementations, and static code and static types are generated in the background. However, the behaviour is still dynamic, the compiler only generates static types when it finds that the dynamic aspects are not used for a specific object.

这篇关于这是什么意思,JavaScript是“动态的”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆