什么是“原生JavaScript”? [英] What is "native JavaScript"?

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

问题描述

有什么叫原生JavaScript吗?我在工作描述中看过这个术语我将要面试。

Is there anything called "Native JavaScript"? I have seen this term in a job description I am going to be interviewing.

常规JavaScript是否与Native JavaScript相同?

Is regular JavaScript is same as Native JavaScript?

推荐答案

术语native在JavaScript中被过度使用。

The term "native" is very overused in JavaScript.


  • 通俗地说,它用在Johan的答案中:没有JQuery,Moo,Dojo。

  • Colloquially, it is used as in Johan's answer: no JQuery, Moo, Dojo.

类似于JNI for Java,Google的GWT和类似的I-compile -down-to-JavaScript谈论底层实现是本机的。

Analogous to the JNI for Java, Google's GWT and similar I-compile-down-to-JavaScript talks about the underlying implementation as being native.

原始在JS中使用native,我相信,指的是在ECMAScript中构建和定义的对象,而不是环境。 JavaScript作为一种ECMAScript语言,并不是自给自足的;它嵌入在主机环境中,如Web浏览器,Photoshop,Acroread等。当您编写Web客户端程序时,您将使用 Math ,<$等对象c $ c>功能,数组窗口按钮。前三个是 native (独立于主机环境),而后两个是非本机的(由主机环境提供)。这与cdhowie的答案相反,这是一个很好的答案BTW。但是很有趣!

The original use of native in JS, I believe, refers to objects built and defined in ECMAScript as opposed to the environment. JavaScript, as an ECMAScript language, is not intended to be self-sufficient; it is embedded in a host environment such as a Web browser, Photoshop, Acroread, etc. When you write a web client program, you will use objects such as Math, Function, Array, Window, and Button. The first three are native (independent of host environment), while the last two are non-native (supplied by the host environment). This is kind of the opposite of cdhowie's answer, which is a good answer BTW. Just interesting, though!

我确定还有其他解释。我的猜测是,如果你在工作描述中看到这一点,那可能不是最后一个:那个定义过于学术化了。 :)

I'm sure there are other interpretations. My guess is that if you see this in a job description, it's probably not the last one: that definition is too academic. :)

以下是ECMAScript-262标准版第五版的官方定义:

Here is the official definition from the ECMAScript-262 Standard, Fifth Edition:

4.3.6 native object --- object in an ECMAScript implementation 
whose semantics are fully defined by this specification rather 
than by the host environment. NOTE Standard native objects are 
defined in this specification. Some native objects are built-in; 
others may be constructed during the course of execution of an 
ECMAScript program.

换句话说,内置插件如 Math 对象字符串 RegExp 是原生的,如是我用对象文字或函数定义创建的任何对象。但主机对象则相反。对不起絮絮叨叨。

In other words the built-ins like Math, Object, String, RegExp are native, as are any objects I make with object literals or function definitions. But host objects are the opposite. Sorry for the ramble.

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

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