一切都是物体吗? [英] Everything is an object?

查看:103
本文介绍了一切都是物体吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个受欢迎的博客上,作者问他的听众他们的啊哈!"是什么?关于JavaScript的片刻,大多数人说这是在意识到JavaScript中的所有内容都是一个对象.但是,对于JS和编程新手来说,我不太了解这意味着什么.它不像它与实际的JS对象有关-https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object

At one popular blog, the author asked his audience what was their "Ah ha!" moment for JavaScript and most of the people said that it was realizing that everything in JavaScript is an object. But being new to JS and programming in general I don't quite get what that means. It doesn't seam like it's related to actual JS Object - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object

或者是吗?

如果不能,请解释一下"JavaScript中的所有对象都是对象"是什么意思.

If it doesn't could you please explain what do they mean by "everything in JavaScript is an object".

或者这全是关于OO编程的,阅读有关该主题的内容将有助于理解它?您能推荐阅读有关该主题的内容吗?

Or it's all about OO Programming in general and reading something on this subject will help to understand it? Can you recommend what to read on this topic?

推荐答案

回到第一原理.

什么是物体?它是一个软件组件,将状态和行为一起封装到内存中的单个实体中.

What's an object? It's a software component that encapsulates state and behavior together into a single entity in memory.

通过该定义,您可以看到可以将所有内容视为对象的地方.函数式程序员使函数成为第一类对象.数据人们会说,即使没有行为,数据也可以被认为是一种对象(尽管不是很聪明).

By that definition, you can see where everything can be thought of as an object. Functional programmers make functions first class objects. Data folks would say that data, even that without behavior, can be thought of as an object (albeit not a very smart one).

我看不到这会发生什么变化.

I don't see what this changes.

JavaScript将函数视为对象.

JavaScript treats functions as objects.

我不确定这种见识会对您的编程产生什么影响.

I'm not sure what effect this insight will have on your programming.

这篇关于一切都是物体吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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